From 299f5708a2274d069c624073ca3958f8625faf35 Mon Sep 17 00:00:00 2001 From: ima1zumi Date: Tue, 22 Dec 2020 00:59:48 +0900 Subject: [ruby/reline] Fixed an exception occurred when ambiguous width character was passed to `#calculate_width` [Bug #17405] https://github.com/ruby/reline/commit/f79b4c857f --- lib/reline.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/reline.rb b/lib/reline.rb index 339b8bc8d7..4c26ac7266 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -36,7 +36,7 @@ module Reline attr_accessor :config attr_accessor :key_stroke attr_accessor :line_editor - attr_accessor :ambiguous_width + attr_writer :ambiguous_width attr_accessor :last_incremental_search attr_reader :output @@ -356,9 +356,14 @@ module Reline end end + def ambiguous_width + may_req_ambiguous_char_width unless defined? @ambiguous_width + @ambiguous_width + end + private def may_req_ambiguous_char_width @ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File) - return if ambiguous_width + return if @ambiguous_width Reline::IOGate.move_cursor_column(0) begin output.write "\u{25bd}" -- cgit v1.2.3