From: Eli Zaretskii Date: Mon, 13 Mar 2017 16:15:09 +0000 (+0200) Subject: Fix bidi paragraph direction when inserting text at newline X-Git-Tag: emacs-26.0.90~578 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f591765e2b6b9ec3fa3ff647c77a10c984f78133;p=emacs.git Fix bidi paragraph direction when inserting text at newline * src/insdel.c (invalidate_buffer_caches): Invalidate the bidi paragraph cache when inserting immediately after a newline. (Bug#26083) --- diff --git a/src/insdel.c b/src/insdel.c index e4ad9a2dec3..0a2e07a343f 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -2001,18 +2001,21 @@ invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) see below). */ if (buf->bidi_paragraph_cache) { - if (start != end - && start > BUF_BEG (buf)) + if (start > BUF_BEG (buf)) { /* If we are deleting or replacing characters, we could create a paragraph start, because all of the characters from START to the beginning of START's line are whitespace. Therefore, we must extend the region to be - invalidated up to the newline before START. */ + invalidated up to the newline before START. Similarly, + if we are inserting characters immediately after a + newline, we could create a paragraph start if the + inserted characters start with a newline. */ ptrdiff_t line_beg = start; ptrdiff_t start_byte = buf_charpos_to_bytepos (buf, start); + int prev_char = BUF_FETCH_BYTE (buf, start_byte - 1); - if (BUF_FETCH_BYTE (buf, start_byte - 1) != '\n') + if ((start == end) == (prev_char == '\n')) { struct buffer *old = current_buffer;