From: Eli Zaretskii Date: Sat, 28 May 2011 11:05:40 +0000 (+0300) Subject: Fix cursor motion near overlays covering reordered text. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~37 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c40e2fb22c6f1e21b63209574b75daaee853123f;p=emacs.git Fix cursor motion near overlays covering reordered text. src/xdisp.c (set_cursor_from_row): Set start and stop points of the loop that looks for the glyph on which to display cursor according to the row's direction. --- diff --git a/src/ChangeLog b/src/ChangeLog index f7807b90941..b651856f276 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-05-28 Eli Zaretskii + + * xdisp.c (set_cursor_from_row): Set start and stop points of the + loop that looks for the glyph on which to display cursor according + to the row's direction. + 2011-05-21 Eli Zaretskii * xdisp.c (handle_display_spec): New function, refactored from the diff --git a/src/xdisp.c b/src/xdisp.c index dfeb3448525..9d5ec9f1f60 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12818,11 +12818,30 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, GLYPH_BEFORE and GLYPH_AFTER, and it came from a string positioned between POS_BEFORE and POS_AFTER in the buffer. */ - struct glyph *stop = glyph_after; + struct glyph *start, *stop; EMACS_INT pos = pos_before; x = -1; - for (glyph = glyph_before + incr; + + /* GLYPH_BEFORE and GLYPH_AFTER are the glyphs that + correspond to POS_BEFORE and POS_AFTER, respectively. We + need START and STOP in the order that corresponds to the + row's direction as given by its reversed_p flag. If the + directionality of characters between POS_BEFORE and + POS_AFTER is the opposite of the row's base direction, + these characters will have been reordered for display, + and we need to reverse START and STOP. */ + if (!row->reversed_p) + { + start = min (glyph_before, glyph_after); + stop = max (glyph_before, glyph_after); + } + else + { + start = max (glyph_before, glyph_after); + stop = min (glyph_before, glyph_after); + } + for (glyph = start + incr; row->reversed_p ? glyph > stop : glyph < stop; ) {