Subject: bug#70000: 29.2; Grapheme handling incorrect

From: Phillip Susi <[email-masked]>
Date: Wed, 27 Mar 2024 10:11:30 -0400

Eli Zaretskii <[email-masked]> writes:

> Querying the cursor position won't help in this case because it is
> Emacs that moves the cursor when you type C-f, not the terminal.

I'm not talking about C-f, but simply displaying the characters on the
screen.  Emacs assumes the width is 4 when it prints this character, and
so it thinks that the cursor moved over 4 places.  When the terminal
actually only moves the cursor over 2 spaces, emacs gets out of sync
with the terminal, and massive breakage occurs.

By reading back the cursor position from the terminal after displaying a
grapheme cluster, it would learn how the terminal displayed it and
update its idea of where the cursor is correctly.

I originally ran into this problem not with a ZWJ, but with an emoji
followed by alternate selector 16 that someone used in a subject line of
an email, and when browsing my inbox with notmuch, the terminal went
FUBAR.