From e29fb7dfba96e63cb7ba2d2a68f91f8dec336100 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 6 Jun 2019 17:12:57 +0300 Subject: [PATCH] Fix redisplay glitches with RTL composed text * src/xdisp.c (init_to_row_end): Fail if the first visible position on the line following ROW is bidi-reordered and could be composed. (Bug#35811) --- src/xdisp.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 5f438152341..aa10abeb191 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3407,7 +3407,8 @@ init_to_row_start (struct it *it, struct window *w, struct glyph_row *row) /* Initialize IT for stepping through current_buffer in window W starting in the line following ROW, i.e. starting at ROW->end. Value is false if there are overlay strings with newlines at ROW's - end position. */ + end position, or if the following row begins with bidi-reordered + characters that could be composed. */ static bool init_to_row_end (struct it *it, struct window *w, struct glyph_row *row) @@ -3420,7 +3421,20 @@ init_to_row_end (struct it *it, struct window *w, struct glyph_row *row) it->continuation_lines_width = row->continuation_lines_width + row->pixel_width; CHECK_IT (it); - success = true; + /* Initializing IT in the presense of compositions in reordered + rows is tricky: row->end above will generally cause us to + start at position that is not the first one in the logical + order, and we might therefore miss the composition earlier in + the buffer that affects how glypsh are laid out in this row. + So we punt instead. Note: the test below works because + get_next_display_element calls get_visually_first_element, + which calls composition_compute_stop_pos, which populates + it->cmp_it. */ + if (get_next_display_element (it) + && (it->bidi_it.scan_dir == -1 && it->cmp_it.id >= 0)) + success = false; + else + success = true; } return success; -- 2.39.2