From 29413665c55b2597d875f715a6ee601be4d518c8 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 9 Sep 2021 18:06:59 -0700 Subject: [PATCH] Treat Fitzpatrick emoji modifiers as width 0 Fixes #8275 --- CHANGELOG.rst | 3 ++- src/fallback.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 42dbcdec9..af8b4383c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -108,7 +108,8 @@ Improved terminal support - Dynamic terminal titles are enabled on WezTerm (:issue:`8121`). - Directory history navigation works out of the box with Apple Terminal's default key settings (:issue:`2330`). - fish now assumes Unicode 9+ widths for emoji under iTerm 2 (:issue:`8200`). -- fish's escape sequence removal now also knows Tmux' wrapped escapes. +- Skin-tone emoji modifiers (U+1F3FB through U+1F3FF) are now measured as width 0 (:issue:`8275`). +- fish's escape sequence removal now also knows Tmux's wrapped escapes. Other improvements ------------------------------ diff --git a/src/fallback.cpp b/src/fallback.cpp index e99d0311e..1e1385ab9 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -260,6 +260,12 @@ int fish_wcwidth(wchar_t wc) { // or standalone with a 1 width. Since that's literally not expressible with wcwidth(), // we take the position that the typical way for them to show up is composed. if (wc >= L'\u1160' && wc <= L'\u11FF') return 0; + + // Check for Emoji_Modifier property. Only the Fitzpatrick modifiers have this, in range + // 1F3FB..1F3FF. This is a hack because such an emoji appearing on its own would be drawn as + // width 2, but that's unlikely to be useful. See #8275. + if (wc >= 0x1F3FB && wc <= 0x1F3FF) return 0; + int width = widechar_wcwidth(wc); switch (width) {