Subject: Re: bug#76538: 31.0.50; 31.0.50; 31.0.50; feature/igc: using magit-section-cycle-global (S-TAB) and magit-section-toggle (TAB) in some random ways blocks GNU Emacs.

From: Eli Zaretskii <[email-masked]>
Date: Mon, 03 Mar 2025 16:13:32 +0200

> Date: Mon, 03 Mar 2025 10:42:25 +0000
> From: Pip Cet <[email-masked]>
> Cc: Helmut Eller <[email-masked]>, Stefan Monnier <[email-masked]>, Ihor Radchenko <[email-masked]>, Eli Zaretskii <[email-masked]>, [email-masked], [email-masked]
> 
> I have no idea why I hit the assert which required the second patch.

Which assertion was that?  Is there any way of triggering that on the
master branch, or on the igc branch without first applying the patch?

> It seems to me like a bug in the xdisp.c code, but it's xdisp.c, so
> who knows?

I suspect it->len is not used when the character is composed, because
the actual character in the buffer text is not relevant in that case,
as the results of the composition determine how many bytes to skip to
get to the next "display element".

> -	it->c = STRING_CHAR (s);
> +	{
> +	  it->c = STRING_CHAR (s);
> +	  it->len = CHAR_BYTES (it->c);
> +	}

This is sub-optimal; please use string_char_and_length instead.

> @@ -6724,6 +6730,7 @@ handle_composition_prop (struct it *it)
>        pos_byte = IT_BYTEPOS (*it);
>        string = Qnil;
>        it->c = FETCH_CHAR (pos_byte);
> +      it->len = it->multibyte_p ? CHAR_BYTES (it->c) : 1;

Likewise here.