1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Suppress error when check ambiguous char width in LANG=C

https://github.com/ruby/reline/commit/623dffdd75
This commit is contained in:
aycabta 2020-03-24 13:56:22 +09:00
parent 8911b3d3e8
commit 69cd27c98e

View file

@ -336,8 +336,14 @@ module Reline
@ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
return if ambiguous_width
Reline::IOGate.move_cursor_column(0)
output.write "\u{25bd}"
@ambiguous_width = Reline::IOGate.cursor_pos.x
begin
output.write "\u{25bd}"
rescue Encoding::UndefinedConversionError
# LANG=C
@ambiguous_width = 1
else
@ambiguous_width = Reline::IOGate.cursor_pos.x
end
Reline::IOGate.move_cursor_column(0)
Reline::IOGate.erase_after_cursor
end