Skip to content

Commit 623dffd

Browse files
committed
Suppress error when check ambiguous char width in LANG=C
1 parent e036798 commit 623dffd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/reline.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,14 @@ def readline(prompt = '', add_hist = false)
336336
@ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
337337
return if ambiguous_width
338338
Reline::IOGate.move_cursor_column(0)
339-
output.write "\u{25bd}"
340-
@ambiguous_width = Reline::IOGate.cursor_pos.x
339+
begin
340+
output.write "\u{25bd}"
341+
rescue Encoding::UndefinedConversionError
342+
# LANG=C
343+
@ambiguous_width = 1
344+
else
345+
@ambiguous_width = Reline::IOGate.cursor_pos.x
346+
end
341347
Reline::IOGate.move_cursor_column(0)
342348
Reline::IOGate.erase_after_cursor
343349
end

0 commit comments

Comments
 (0)