wcwidth: Classify some Hangul Jamo as combiners

Hangul uses three codepoints to combine to one glyph. The first has a
width of 2 (like the final glyph), but the second and third were
assigned a width of 1, which seems to match EastAsianWidth.txt:

> 1160..11FF;N # Lo [160] HANGUL JUNGSEONG FILLER..HANGUL JONGSEONG SSANGNIEUN

Instead, we override that and treat the middle and end codepoint as combiners,
always, because there's no way to figure out what the terminal will
think and that's the way it's supposed to work.

If they stand by themselves or in another combination, they'll indeed
show up with a width of 1 so we'll get it wrong, but that's less
likely and not expressible with wcwidth().

Fixes #5729.
This commit is contained in:
Fabian Homborg
2019-03-12 23:29:03 +01:00
parent 2e4948e1f4
commit b318ab17d2

View File

@@ -287,6 +287,9 @@ int fish_wcwidth(wchar_t wc) {
if (wc == variation_selector_16) return 1;
else if (wc == variation_selector_15) return 0;
// Korean Hangul Jamo median vowels and final consonants.
// These are effectively combiners, so we handle them like combiners.
if (wc >= L'\u1160' && wc <= L'\u11FF') return wcwidth(wc);
int width = widechar_wcwidth(wc);
switch (width) {
case widechar_nonprint: