Treat Fitzpatrick emoji modifiers as width 0

Fixes #8275
This commit is contained in:
ridiculousfish 2021-09-09 18:06:59 -07:00
parent 40b40a4316
commit 29413665c5
2 changed files with 8 additions and 1 deletions

View File

@ -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
------------------------------

View File

@ -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) {