On Mon, Nov 04, 2002 at 10:47:00AM +0000, Angus Leeming wrote:
> No, the warning is generated in MathArray::notifyCursorLeaves() immediately
> below your snippet:
> // glue adjacent font insets of the same kind
> for (pos_type i = 0; i + 1 < size(); ++i) {
> MathFontInset * p = operator[](i).nucleus()->asFontInset();
> MathFontInset const * q = operator[](i + 1)->asFontInset();
> if (p && q && p->name() == q->name()) {
> p->cell(0).append(q->cell(0));
> erase(i + 1);
> - mathcursor->adjust(i, -1);
> + mathcursor->adjust(i, npos);
> }
> }
>
> npos would make that more understandable.
But it is a '-1' which takes care of the one item removed by erase().
It is not the 'npos' concept ("last thing in a string").
> My problem, however, lies with:
> void MathCursor::adjust(pos_type from, size_type size)
> {
> if (cursor().pos_ > from)
> cursor().pos_ += size;
> if (Anchor_.back().pos_ > from)
> Anchor_.back().pos_ += size;
> // just to be on the safe side
> // theoretically unecessary
> normalize();
> }
> I suspect this method needs
> if (size == size_type)-1)
> return;
> (or npos of course). As it stands it doesn't look as if it can cope with an
> invalid size.
What is "invalid" size? An "adjustment" of -1 means everything (i.e. the
Anchor) in the current cell behind the cursor has to be moved "one to the
left", because at cursor position 1 thing got deleted.
Maybe the problem is the size_type size argument, which should be a
'diff_type diff' argument...
Andre'
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)