Subject: Re: bug#41626: 28.0.50; activating mark breaks RTL shaping in etc/HELLO (auto-composition-mode)

From: Pip Cet <[email-masked]>
Date: Sun, 31 May 2020 17:08:56 +0000

On Sun, May 31, 2020 at 2:59 PM Eli Zaretskii <[email-masked]> wrote:
> > From: Pip Cet <[email-masked]>
> > Date: Sun, 31 May 2020 13:10:47 +0000
> > Cc: [email-masked]
> >
> > What I don't understand is why it works in pure RTL paragraphs,
> > though. If I yank the Arabic greeting into a new buffer, I can place
> > the mark anywhere and nothing happens to the shaping.
>
> Because testing where the face changes while going backwards in a
> buffer is "tricky".  See handle_stop_backwards and its callers.

Thanks!

I don't see why we need to invalidate composition state in
handle_stop_backwards.

How's this?
From 01fe1722036e6cbbf428e2068a666c36d718c74e Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Date: Sun, 31 May 2020 16:58:19 +0000
Subject: [PATCH] Avoid losing composition state in handle_stop_backwards

* src/xdisp.c (handle_stop_backwards): Save composition iterator state
across our forward scan.
---
 src/xdisp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index ea28395cf5..e93b0bc201 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8692,6 +8692,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos)
   ptrdiff_t where_we_are = (bufp ? IT_CHARPOS (*it) : IT_STRING_CHARPOS (*it));
   struct display_pos save_current = it->current;
   struct text_pos save_position = it->position;
+  struct composition_it save_cmp_it = it->cmp_it;
   struct text_pos pos1;
   ptrdiff_t next_stop;
 
@@ -8719,6 +8720,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos)
   it->bidi_p = true;
   it->current = save_current;
   it->position = save_position;
+  it->cmp_it = save_cmp_it;
   next_stop = it->stop_charpos;
   it->stop_charpos = it->prev_stop;
   handle_stop (it);
-- 
2.27.0.rc0