summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorima1zumi <mariimaizumi5@gmail.com>2020-12-22 00:59:48 +0900
committeraycabta <aycabta@gmail.com>2020-12-22 23:45:43 +0900
commit299f5708a2274d069c624073ca3958f8625faf35 (patch)
treeb3b71c513ac60c59bcb6fc2bbf4e48b7e73660cc /lib
parentb52bc4a9c29e80e10b7e64dbebd97117916d3982 (diff)
[ruby/reline] Fixed an exception occurred when ambiguous width character was passed to `#calculate_width` [Bug #17405]
https://github.com/ruby/reline/commit/f79b4c857f
Diffstat (limited to 'lib')
-rw-r--r--lib/reline.rb9
1 files changed, 7 insertions, 2 deletions
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}"