[ruby/reline] Return 1 when char width not found

This fixes ruby/reline#261.

3cf1213014
This commit is contained in:
aycabta 2021-02-15 00:27:51 +09:00
parent b88be10094
commit dc9e33016c
2 changed files with 9 additions and 0 deletions

View file

@ -108,6 +108,7 @@ class Reline::Unicode
end
m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE)
case
when m.nil? then 1 # TODO should be U+FFFD <20> REPLACEMENT CHARACTER
when m[:width_2_1], m[:width_2_2] then 2
when m[:width_3] then 3
when m[:width_0] then 0