Incorporate widecharwidth changes for narrow emoji

This pulls in widechar_width.h from commit 7e9dfdaf05059b3f. The big change
here is that some characters which were previously marked as widened in 9
are now marked as unconditionally narrow; this includes some randoms like
hot pepper (U+1F336) but more importantly all of the regional indicators,
which affects how flags are rendered.

If you put two regional indicators together, you get a flag emoji. It's
unclear what the width of this flag emoji should be; Terminal and iTerm2
renders it as width 1, while kitty renders it as width 2. This is
unaffected by fish_emoji_width because the flag does not have an assigned
codepoint, it is a pair of codepoints.

The regional indicators are marked as "neutral" in EastAsianWidth.txt which
means they conceptually have width 1. So two of them have width 2. So now
we assume that flags are rendered as width 2.

This fixes #7237, for terminals that render flags as width 2 (but not 1,
unfortunately, which includes iTerm2 and Terminal.app).
This commit is contained in:
ridiculousfish 2020-08-04 12:34:19 -07:00
parent c9bcb52fe9
commit 81f9f51bcb
2 changed files with 21 additions and 18 deletions

View file

@ -104,6 +104,7 @@ Improved terminal output
- The cursor shape in Vi mode changes properly in Windows Terminal (#6999).
- The spurious warning about terminal size in small terminals has been removed (#6980).
- Dynamic titles are now enabled in Alacritty with its new terminfo entry (#7073).
- The width computation for certain emoji agrees better with terminals. In particular, flags now have width 2. (#7237).
Completions
^^^^^^^^^^^

View file

@ -181,15 +181,14 @@ static const struct widechar_range widechar_doublewide_table[] = {
{0x0FF01, 0x0FF60}, {0x0FFE0, 0x0FFE6}, {0x16FE0, 0x16FE4},
{0x16FF0, 0x16FF1}, {0x17000, 0x187F7}, {0x18800, 0x18CD5},
{0x18D00, 0x18D08}, {0x1B000, 0x1B11E}, {0x1B150, 0x1B152},
{0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, {0x1F12F, 0x1F12F},
{0x1F16C, 0x1F16C}, {0x1F200, 0x1F200}, {0x1F210, 0x1F219},
{0x1F21B, 0x1F22E}, {0x1F230, 0x1F231}, {0x1F23B, 0x1F23B},
{0x1F240, 0x1F248}, {0x1F260, 0x1F265}, {0x1F57A, 0x1F57A},
{0x1F5A4, 0x1F5A4}, {0x1F6D1, 0x1F6D7}, {0x1F6F4, 0x1F6FC},
{0x1F7D5, 0x1F7D8}, {0x1F7E0, 0x1F7EB}, {0x1F90C, 0x1F90F},
{0x1F919, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1F978},
{0x1F97A, 0x1F97F}, {0x1F985, 0x1F9BF}, {0x1F9C1, 0x1F9CB},
{0x1F9CD, 0x1FA53}, {0x1FA60, 0x1FA6D}, {0x1FA70, 0x1FA74},
{0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, {0x1F200, 0x1F200},
{0x1F210, 0x1F219}, {0x1F21B, 0x1F22E}, {0x1F230, 0x1F231},
{0x1F23B, 0x1F23B}, {0x1F240, 0x1F248}, {0x1F260, 0x1F265},
{0x1F57A, 0x1F57A}, {0x1F5A4, 0x1F5A4}, {0x1F6D1, 0x1F6D2},
{0x1F6D5, 0x1F6D7}, {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB},
{0x1F90C, 0x1F90F}, {0x1F919, 0x1F93A}, {0x1F93C, 0x1F945},
{0x1F947, 0x1F978}, {0x1F97A, 0x1F97F}, {0x1F985, 0x1F9BF},
{0x1F9C1, 0x1F9CB}, {0x1F9CD, 0x1F9FF}, {0x1FA70, 0x1FA74},
{0x1FA78, 0x1FA7A}, {0x1FA80, 0x1FA86}, {0x1FA90, 0x1FAA8},
{0x1FAB0, 0x1FAB6}, {0x1FAC0, 0x1FAC2}, {0x1FAD0, 0x1FAD6},
{0x20000, 0x2FFFD}, {0x30000, 0x3FFFD}
@ -496,15 +495,18 @@ static const struct widechar_range widechar_unassigned_table[] = {
/* Characters that were widened from with 1 to 2 in Unicode 9. */
static const struct widechar_range widechar_widened_table[] = {
{0x1F000, 0x1F02B}, {0x1F030, 0x1F093}, {0x1F0A0, 0x1F0AE},
{0x1F0B1, 0x1F0BF}, {0x1F0C1, 0x1F0CF}, {0x1F0D1, 0x1F0F5},
{0x1F170, 0x1F171}, {0x1F17E, 0x1F17F}, {0x1F18E, 0x1F18E},
{0x1F191, 0x1F19A}, {0x1F1E6, 0x1F1FF}, {0x1F201, 0x1F202},
{0x1F21A, 0x1F21A}, {0x1F22F, 0x1F22F}, {0x1F232, 0x1F23A},
{0x1F250, 0x1F251}, {0x1F300, 0x1F53D}, {0x1F546, 0x1F579},
{0x1F57B, 0x1F5A3}, {0x1F5A5, 0x1F64F}, {0x1F680, 0x1F6D0},
{0x1F6E0, 0x1F6EC}, {0x1F6F0, 0x1F6F3}, {0x1F910, 0x1F918},
{0x1F980, 0x1F984}, {0x1F9C0, 0x1F9C0}, {0xE0020, 0xE007F}
{0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F170, 0x1F171},
{0x1F17E, 0x1F17F}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A},
{0x1F201, 0x1F202}, {0x1F21A, 0x1F21A}, {0x1F22F, 0x1F22F},
{0x1F232, 0x1F23A}, {0x1F250, 0x1F251}, {0x1F300, 0x1F320},
{0x1F32D, 0x1F335}, {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393},
{0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0},
{0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440},
{0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E},
{0x1F550, 0x1F567}, {0x1F595, 0x1F596}, {0x1F5FB, 0x1F64F},
{0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D0},
{0x1F6EB, 0x1F6EC}, {0x1F910, 0x1F918}, {0x1F980, 0x1F984},
{0x1F9C0, 0x1F9C0}
};
template<typename Collection>