]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Update other comment.
[lyx.git] / src / Cursor.cpp
index 89db3a6dd00acdb609f8074143964e1e92a953ec..964b593f231138fe62b0e3eacaa791ad9c843475 100644 (file)
@@ -635,7 +635,6 @@ bool Cursor::posVisRight(bool skip_inset)
        Cursor new_cur = *this; // where we will move to
        pos_type left_pos; // position visually left of current cursor
        pos_type right_pos; // position visually right of current cursor
-       bool new_pos_is_RTL; // is new position we're moving to RTL?
 
        getSurroundingPos(left_pos, right_pos);
 
@@ -679,7 +678,7 @@ bool Cursor::posVisRight(bool skip_inset)
                // we're currently to the left of 'right_pos'). In
                // order to move to the right, it depends whether or
                // not the character at 'right_pos' is RTL.
-               new_pos_is_RTL = paragraph().getFontSettings(
+               bool const new_pos_is_RTL = paragraph().getFontSettings(
                        buffer()->params(), right_pos).isVisibleRightToLeft();
                // If the character at 'right_pos' *is* LTR, then in
                // order to move to the right of it, we need to be
@@ -735,7 +734,6 @@ bool Cursor::posVisLeft(bool skip_inset)
        Cursor new_cur = *this; // where we will move to
        pos_type left_pos; // position visually left of current cursor
        pos_type right_pos; // position visually right of current cursor
-       bool new_pos_is_RTL; // is new position we're moving to RTL?
 
        getSurroundingPos(left_pos, right_pos);
 
@@ -779,7 +777,7 @@ bool Cursor::posVisLeft(bool skip_inset)
                // currently to the right of 'left_pos'). In order to
                // move to the left, it depends whether or not the
                // character at 'left_pos' is RTL.
-               new_pos_is_RTL = paragraph().getFontSettings(
+               bool const new_pos_is_RTL = paragraph().getFontSettings(
                        buffer()->params(), left_pos).isVisibleRightToLeft();
                // If the character at 'left_pos' *is* RTL, then in
                // order to move to the left of it, we need to be
@@ -2107,17 +2105,13 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                                next_row = 0;
                        }
                }
-               top().pos() = min(tm.x2pos(pit(), next_row, xo), top().lastpos());
 
-               int const xpos = tm.x2pos(pit(), next_row, xo);
-               bool const at_end_row = xpos == tm.x2pos(pit(), next_row, tm.width());
-               bool const at_beg_row = xpos == tm.x2pos(pit(), next_row, 0);
-
-               if (at_end_row && at_beg_row)
-                       // make sure the cursor ends up on this row
-                       boundary(false);
-               else
-                       boundary(at_end_row);
+               Row const & real_next_row = tm.parMetrics(pit()).rows()[next_row];
+               bool bound = false;
+               pos_type const col = tm.getColumnNearX(pit(), real_next_row, 
+                                                      xo, bound);
+               top().pos() = real_next_row.pos() + col;
+               boundary(bound);
 
                updateNeeded |= bv().checkDepm(*this, old);
        }