From a85cde3870d61cb9cc6662e5ec6245f474146f7e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 28 May 2010 15:00:47 +0300 Subject: [PATCH] Prevent unnecessary scrolling in bidi-reordered buffers. xdisp.c (try_cursor_movement): back up to non-continuation line only after finding point's row.. --- src/ChangeLog | 5 +++++ src/xdisp.c | 58 +++++++++++++++++++++++++++------------------------ 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index eeee6540e68..a530e844bf9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-05-28 Eli Zaretskii + + * xdisp.c (try_cursor_movement): Prevent unnecessary scrolling in + bidi-reordered buffers. + 2010-05-28 Kenichi Handa * font.c (font_delete_unmatched): Check Vface_ignored_fonts. diff --git a/src/xdisp.c b/src/xdisp.c index 31fa5f39d5f..a94049a780b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13763,32 +13763,6 @@ try_cursor_movement (window, startp, scroll_step) ++row; if (!row->enabled_p) rc = CURSOR_MOVEMENT_MUST_SCROLL; - /* If rows are bidi-reordered, back up until we find a row - that does not belong to a continuation line. This is - because we must consider all rows of a continued line as - candidates for cursor positioning, since row start and - end positions change non-linearly with vertical position - in such rows. */ - /* FIXME: Revisit this when glyph ``spilling'' in - continuation lines' rows is implemented for - bidi-reordered rows. */ - if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)) - { - while (MATRIX_ROW_CONTINUATION_LINE_P (row)) - { - xassert (row->enabled_p); - --row; - /* If we hit the beginning of the displayed portion - without finding the first row of a continued - line, give up. */ - if (row <= w->current_matrix->rows) - { - rc = CURSOR_MOVEMENT_MUST_SCROLL; - break; - } - - } - } } if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED) @@ -13888,7 +13862,37 @@ try_cursor_movement (window, startp, scroll_step) rc = CURSOR_MOVEMENT_MUST_SCROLL; } else if (rc != CURSOR_MOVEMENT_SUCCESS - && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) + && !NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + { + /* If rows are bidi-reordered and point moved, back up + until we find a row that does not belong to a + continuation line. This is because we must consider + all rows of a continued line as candidates for the + new cursor positioning, since row start and end + positions change non-linearly with vertical position + in such rows. */ + /* FIXME: Revisit this when glyph ``spilling'' in + continuation lines' rows is implemented for + bidi-reordered rows. */ + while (MATRIX_ROW_CONTINUATION_LINE_P (row)) + { + xassert (row->enabled_p); + --row; + /* If we hit the beginning of the displayed portion + without finding the first row of a continued + line, give up. */ + if (row <= w->current_matrix->rows) + { + rc = CURSOR_MOVEMENT_CANNOT_BE_USED; + break; + } + + } + } + if (rc == CURSOR_MOVEMENT_SUCCESS + || rc == CURSOR_MOVEMENT_CANNOT_BE_USED) + ; + else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) && make_cursor_line_fully_visible_p) { if (PT == MATRIX_ROW_END_CHARPOS (row) -- 2.39.2