This is making life hard for me.

I just don't understand why the cursor does not change, or am I just
looking at the wrong cursors.

This is the problematic code:

bool LyXText::cursorUp(LCursor & cur)
{
        Paragraph const & par = cur.paragraph();
        int const row = par.pos2row(cur.pos());
        int const x = cur.targetX();

        if (!cur.selection()) {
                lyxerr << BOOST_CURRENT_FUNCTION
                       << "Cursor up, no selection" << endl;

                int const y = bv_funcs::getPos(cur).y_;
                LCursor old = cur;
                editXY(cur, x, y - par.rows()[row].ascent() - 1);
                if (cur == old)
                        lyxerr << BOOST_CURRENT_FUNCTION
                               << " cur and old ARE EQUAL!\n"
                               << "old: " << old <<'\n'
                               << "cur: " << cur << endl;

                        return deleteEmptyParagraphMechanism(cur, old);
        }
        
        bool updateNeeded = false;

        if (row > 0) {
                updateNeeded |= setCursor(cur, cur.pit(), x2pos(cur.pit(), row 
- 1, x));
        } else if (cur.pit() > 0) {
                --cur.pit();
                updateNeeded |= setCursor(cur, cur.pit(), x2pos(cur.pit(), 
par.rows().size() - 1, x));
        }

        cur.x_target() = x;

        return updateNeeded;
}


The problem case if when you have a paragraph with text and an open
inset in it. When you then stand at the top line of the inset, insert
an extra space between to words and press 'up'. The cursor now moves
out of the inset and into the line above. Fine and dandy. This is done
by hte editXY in the code above. However, what is not so fine is that
old == cur even after this, so DEPM ends up doing nothing and we are
left with a double-space.

There certainly must be some detail that I am missing.

(All this goes for 'down' (cursorDown) as well.)

-- 
        Lgb

Reply via email to