aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2017-03-13 18:15:09 +0200
committerEli Zaretskii2017-03-13 18:15:09 +0200
commitf591765e2b6b9ec3fa3ff647c77a10c984f78133 (patch)
treee4bdf2f21ca5cca23b45b868e582f98979b1ce0a /src
parent7a50abee22581e02f0d822c3d9684c0985cdecb2 (diff)
downloademacs-f591765e2b6b9ec3fa3ff647c77a10c984f78133.tar.gz
emacs-f591765e2b6b9ec3fa3ff647c77a10c984f78133.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c11
1 files changed, 7 insertions, 4 deletions
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)
2001 see below). */ 2001 see below). */
2002 if (buf->bidi_paragraph_cache) 2002 if (buf->bidi_paragraph_cache)
2003 { 2003 {
2004 if (start != end 2004 if (start > BUF_BEG (buf))
2005 && start > BUF_BEG (buf))
2006 { 2005 {
2007 /* If we are deleting or replacing characters, we could 2006 /* If we are deleting or replacing characters, we could
2008 create a paragraph start, because all of the characters 2007 create a paragraph start, because all of the characters
2009 from START to the beginning of START's line are 2008 from START to the beginning of START's line are
2010 whitespace. Therefore, we must extend the region to be 2009 whitespace. Therefore, we must extend the region to be
2011 invalidated up to the newline before START. */ 2010 invalidated up to the newline before START. Similarly,
2011 if we are inserting characters immediately after a
2012 newline, we could create a paragraph start if the
2013 inserted characters start with a newline. */
2012 ptrdiff_t line_beg = start; 2014 ptrdiff_t line_beg = start;
2013 ptrdiff_t start_byte = buf_charpos_to_bytepos (buf, start); 2015 ptrdiff_t start_byte = buf_charpos_to_bytepos (buf, start);
2016 int prev_char = BUF_FETCH_BYTE (buf, start_byte - 1);
2014 2017
2015 if (BUF_FETCH_BYTE (buf, start_byte - 1) != '\n') 2018 if ((start == end) == (prev_char == '\n'))
2016 { 2019 {
2017 struct buffer *old = current_buffer; 2020 struct buffer *old = current_buffer;
2018 2021