From 69cd27c98eafd8711056825cf6c378eee282ffaa Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 24 Mar 2020 13:56:22 +0900 Subject: [PATCH] [ruby/reline] Suppress error when check ambiguous char width in LANG=C https://github.com/ruby/reline/commit/623dffdd75 --- lib/reline.rb | 10 ++++++++-- 1 file 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