]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bidi paragraph direction when inserting text at newline
authorEli Zaretskii <eliz@gnu.org>
Mon, 13 Mar 2017 16:15:09 +0000 (18:15 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 13 Mar 2017 16:15:09 +0000 (18:15 +0200)
* src/insdel.c (invalidate_buffer_caches): Invalidate the bidi
paragraph cache when inserting immediately after a newline.
(Bug#26083)

src/insdel.c

index e4ad9a2dec3015c7978d9668bce5fd993a180600..0a2e07a343fbb218fd41c8ca77cb686c6120efba 100644 (file)
@@ -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;