Commit 6d26bbb2 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Finish debugging of cursor motion in bidi-reordered lines.

 xdisp.c (try_cursor_movement): Fix the logic.  Rewrite the loop
 over continuation lines in bidi-reordered buffers.  Return
 CURSOR_MOVEMENT_MUST_SCROLL upon failure to find a suitable row,
 rather than CURSOR_MOVEMENT_CANNOT_BE_USED.
parent a85cde38
2010-05-29 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (try_cursor_movement): Fix the logic. Rewrite the loop
over continuation lines in bidi-reordered buffers. Return
CURSOR_MOVEMENT_MUST_SCROLL upon failure to find a suitable row,
rather than CURSOR_MOVEMENT_CANNOT_BE_USED.
2010-05-28 Eli Zaretskii <eliz@gnu.org> 2010-05-28 Eli Zaretskii <eliz@gnu.org>
   
* xdisp.c (try_cursor_movement): Prevent unnecessary scrolling in * xdisp.c (try_cursor_movement): Backup to non-continuation line
bidi-reordered buffers. only after finding point's row.
   
2010-05-28 Kenichi Handa <handa@m17n.org> 2010-05-28 Kenichi Handa <handa@m17n.org>
   
......
...@@ -13767,7 +13767,7 @@ try_cursor_movement (window, startp, scroll_step) ...@@ -13767,7 +13767,7 @@ try_cursor_movement (window, startp, scroll_step)
   
if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED) if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED)
{ {
int scroll_p = 0; int scroll_p = 0, must_scroll = 0;
int last_y = window_text_bottom_y (w) - this_scroll_margin; int last_y = window_text_bottom_y (w) - this_scroll_margin;
   
if (PT > XFASTINT (w->last_point)) if (PT > XFASTINT (w->last_point))
...@@ -13860,6 +13860,7 @@ try_cursor_movement (window, startp, scroll_step) ...@@ -13860,6 +13860,7 @@ try_cursor_movement (window, startp, scroll_step)
{ {
/* if PT is not in the glyph row, give up. */ /* if PT is not in the glyph row, give up. */
rc = CURSOR_MOVEMENT_MUST_SCROLL; rc = CURSOR_MOVEMENT_MUST_SCROLL;
must_scroll = 1;
} }
else if (rc != CURSOR_MOVEMENT_SUCCESS else if (rc != CURSOR_MOVEMENT_SUCCESS
&& !NILP (XBUFFER (w->buffer)->bidi_display_reordering)) && !NILP (XBUFFER (w->buffer)->bidi_display_reordering))
...@@ -13883,17 +13884,17 @@ try_cursor_movement (window, startp, scroll_step) ...@@ -13883,17 +13884,17 @@ try_cursor_movement (window, startp, scroll_step)
line, give up. */ line, give up. */
if (row <= w->current_matrix->rows) if (row <= w->current_matrix->rows)
{ {
rc = CURSOR_MOVEMENT_CANNOT_BE_USED; rc = CURSOR_MOVEMENT_MUST_SCROLL;
break; break;
} }
   
} }
} }
if (rc == CURSOR_MOVEMENT_SUCCESS if (must_scroll)
|| rc == CURSOR_MOVEMENT_CANNOT_BE_USED)
; ;
else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) else if (rc != CURSOR_MOVEMENT_SUCCESS
&& make_cursor_line_fully_visible_p) && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)
&& make_cursor_line_fully_visible_p)
{ {
if (PT == MATRIX_ROW_END_CHARPOS (row) if (PT == MATRIX_ROW_END_CHARPOS (row)
&& !row->ends_at_zv_p && !row->ends_at_zv_p
...@@ -13919,7 +13920,8 @@ try_cursor_movement (window, startp, scroll_step) ...@@ -13919,7 +13920,8 @@ try_cursor_movement (window, startp, scroll_step)
} }
else if (scroll_p) else if (scroll_p)
rc = CURSOR_MOVEMENT_MUST_SCROLL; rc = CURSOR_MOVEMENT_MUST_SCROLL;
else if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)) else if (rc != CURSOR_MOVEMENT_SUCCESS
&& !NILP (XBUFFER (w->buffer)->bidi_display_reordering))
{ {
/* With bidi-reordered rows, there could be more than /* With bidi-reordered rows, there could be more than
one candidate row whose start and end positions one candidate row whose start and end positions
...@@ -13932,8 +13934,11 @@ try_cursor_movement (window, startp, scroll_step) ...@@ -13932,8 +13934,11 @@ try_cursor_movement (window, startp, scroll_step)
   
do do
{ {
rv |= set_cursor_from_row (w, row, w->current_matrix, if (MATRIX_ROW_START_CHARPOS (row) <= PT
0, 0, 0, 0); && PT <= MATRIX_ROW_END_CHARPOS (row)
&& cursor_row_p (w, row))
rv |= set_cursor_from_row (w, row, w->current_matrix,
0, 0, 0, 0);
/* As soon as we've found the first suitable row /* As soon as we've found the first suitable row
whose ends_at_zv_p flag is set, we are done. */ whose ends_at_zv_p flag is set, we are done. */
if (rv if (rv
...@@ -13944,19 +13949,17 @@ try_cursor_movement (window, startp, scroll_step) ...@@ -13944,19 +13949,17 @@ try_cursor_movement (window, startp, scroll_step)
} }
++row; ++row;
} }
while (MATRIX_ROW_BOTTOM_Y (row) < last_y while ((MATRIX_ROW_CONTINUATION_LINE_P (row)
&& MATRIX_ROW_START_CHARPOS (row) <= PT && MATRIX_ROW_BOTTOM_Y (row) <= last_y)
&& PT <= MATRIX_ROW_END_CHARPOS (row) || (MATRIX_ROW_START_CHARPOS (row) == PT
&& cursor_row_p (w, row)); && MATRIX_ROW_BOTTOM_Y (row) < last_y));
/* If we didn't find any candidate rows, or exited the /* If we didn't find any candidate rows, or exited the
loop before all the candidates were examined, signal loop before all the candidates were examined, signal
to the caller that this method failed. */ to the caller that this method failed. */
if (rc != CURSOR_MOVEMENT_SUCCESS if (rc != CURSOR_MOVEMENT_SUCCESS
&& (!rv && (!rv || MATRIX_ROW_CONTINUATION_LINE_P (row)))
|| (MATRIX_ROW_START_CHARPOS (row) <= PT rc = CURSOR_MOVEMENT_MUST_SCROLL;
&& PT <= MATRIX_ROW_END_CHARPOS (row)))) else if (rv)
rc = CURSOR_MOVEMENT_CANNOT_BE_USED;
else
rc = CURSOR_MOVEMENT_SUCCESS; rc = CURSOR_MOVEMENT_SUCCESS;
} }
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment