From b318ab17d2b3d759d8d844e4e19e7e047f0f7a19 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 12 Mar 2019 23:29:03 +0100 Subject: [PATCH] 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. --- src/fallback.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fallback.cpp b/src/fallback.cpp index b944c0406..2b8dacb62 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -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: