diff options
author | aycabta <aycabta@gmail.com> | 2020-03-24 13:56:22 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-03-26 17:41:21 +0900 |
commit | 69cd27c98eafd8711056825cf6c378eee282ffaa (patch) | |
tree | ac0a046b830817c1a225d42597d23fc5fd2a4199 /lib/reline.rb | |
parent | 8911b3d3e8073970ba0d3b605be8503ee7367e89 (diff) | |
download | ruby-69cd27c98eafd8711056825cf6c378eee282ffaa.tar.gz |
[ruby/reline] Suppress error when check ambiguous char width in LANG=C
https://github.com/ruby/reline/commit/623dffdd75
Diffstat (limited to 'lib/reline.rb')
-rw-r--r-- | lib/reline.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index 2708cd91b5..1537ee7e69 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -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 |