From c5232df875d62ead326d5e90f122ab9ac9798e59 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 6 Jun 2020 13:02:55 +0000 Subject: [PATCH] Handle buffers containing two newlines followed by an RTL char * src/bidi.c (bidi_paragraph_init): Correct handling of initial newlines. (Bug#41506) --- src/bidi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bidi.c b/src/bidi.c index 1017bd2d52..8aa325fe6d 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1714,8 +1714,12 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) s = (STRINGP (bidi_it->string.lstring) ? SDATA (bidi_it->string.lstring) : bidi_it->string.s); - if (bytepos > begbyte - && bidi_char_at_pos (bytepos, s, bidi_it->string.unibyte) == '\n') + /* We always look at the paragraph containing the next character + to be loaded by bidi_level_of_next_char. + + This code happens to work for a buffer containing two + newlines followed by an RTL character (Bug#41506). */ + if (!bidi_it->first_elt) { bytepos++; pos++; -- 2.27.0.rc0