Re: [PATCH v2] utf8: add display_mode_esc_sequence_len_counted()
- From
Andy Koppe <andy.koppe@gmail.com>
- Date
- Nov 18, 2026, 06:59 UTC
- Message-ID
- <CAHWeT-ZcOqm9PXzM5W18+ktJ4gBdPNyx+g_2ZCaW25ufKH4g5A@mail.gmail.com>
- In-Reply-To
- <xmqq33szavmy.fsf@gitster.g>
Junio C Hamano wrote:
Show 15 quoted lines
>
> Andy Koppe <andy.koppe@gmail.com> writes:
>
> > Junio C Hamano wrote:
> >
> >> - while (isdigit(*p) || *p == ';')
> >> + while (p < end && (isdigit(*p) || *p == ';'))
> >
> > While you're there, could you add colons (':') to that?
>
> Do we generate such a sequence that uses subseparators?
>
> IIRC, this code is not counting the display width of end-user
> supplied string. Rather, it gets string we paint in a buffer and
> then counts how much display column it occupies.You're right that Git itself doesn't generate them (although future enhancements might change that).
However, display_mode_esc_sequence_len() already operates on expanded custom formats and message text, e.g. in rewrap_message_tail() via strbuf_wrap(). And on stdin in git-column. They could all contain SGR sequences with colons, whose width currently isn't ignored as intended. (And my proposed make_line_colors_self_contained() wouldn't reset or replay them.)
The check could be changed to `*p >= '0' && *p<=';'` to cheaply include colons.
Andy