mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-04 08:47:11 +00:00
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)
This commit is contained in:
parent
7a50abee22
commit
f591765e2b
11
src/insdel.c
11
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user