From e06ac6d33e6adb7dbd98d782723ec58e8e4eeff0 Mon Sep 17 00:00:00 2001 From: Jacob Sandlund Date: Fri, 20 Feb 2026 12:12:26 -0500 Subject: [PATCH] Force prepend to use wcwidth_standalone --- src/build/uucode_config.zig | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/build/uucode_config.zig b/src/build/uucode_config.zig index 594a05366..d39d4d1e1 100644 --- a/src/build/uucode_config.zig +++ b/src/build/uucode_config.zig @@ -20,12 +20,17 @@ fn computeWidth( _ = backing; _ = tracking; - // This condition is to get the previous behavior of uucode's `wcwidth`, - // returning the width of a code point in a grapheme cluster but with the - // exception to treat emoji modifiers as width 2 so they can be displayed - // in isolation. PRs to follow will take advantage of the new uucode - // `wcwidth_standalone` vs `wcwidth_zero_in_grapheme` split. - if (data.wcwidth_zero_in_grapheme and !data.is_emoji_modifier) { + // This condition is needed as Ghostty currently has a singular concept for + // the `width` of a code point, while `uucode` splits the concept into + // `wcwidth_standalone` and `wcwidth_zero_in_grapheme`. The two cases where + // we want to use the `wcwidth_standalone` despite the code point occupying + // zero width in a grapheme (`wcwidth_zero_in_grapheme`) are emoji + // modifiers and prepend code points. For emoji modifiers we want to + // support displaying them in isolation as color patches, and if prepend + // characters were to be width 0 they would disappear from the output with + // Ghostty's current width 0 handling. Future work will take advantage of + // the new uucode `wcwidth_standalone` vs `wcwidth_zero_in_grapheme` split. + if (data.wcwidth_zero_in_grapheme and !data.is_emoji_modifier and data.grapheme_break_no_control != .prepend) { data.width = 0; } else { data.width = @min(2, data.wcwidth_standalone); @@ -37,6 +42,7 @@ const width = config.Extension{ "wcwidth_standalone", "wcwidth_zero_in_grapheme", "is_emoji_modifier", + "grapheme_break_no_control", }, .compute = &computeWidth, .fields = &.{