From 3d7929050f7ce99fb40f820f898b9943efd007ac Mon Sep 17 00:00:00 2001 From: ima1zumi Date: Sat, 8 Jul 2023 22:06:53 +0900 Subject: [PATCH 1/2] Require Reline 0.3.6 or higher "Multi-line multibyte regular expression raises exception" (https://github.com/ruby/irb/issues/627) is fixed in Reline 0.3.6. --- irb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irb.gemspec b/irb.gemspec index e62429ca7..29f92b59a 100644 --- a/irb.gemspec +++ b/irb.gemspec @@ -41,5 +41,5 @@ Gem::Specification.new do |spec| spec.required_ruby_version = Gem::Requirement.new(">= 2.7") - spec.add_dependency "reline", ">= 0.3.0" + spec.add_dependency "reline", ">= 0.3.6" end From fa2998a9a38286f0dda51cec901c526a911abd1a Mon Sep 17 00:00:00 2001 From: ima1zumi Date: Tue, 11 Jul 2023 21:02:33 +0900 Subject: [PATCH 2/2] Remove unnecessary conditional --- lib/irb/input-method.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 1d47eddea..2c827f900 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -267,9 +267,7 @@ def initialize @stdin = ::IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-") @stdout = ::IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-") - if Reline.respond_to?("basic_word_break_characters=") - Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS - end + Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS Reline.completion_append_character = nil Reline.completer_quote_characters = '' Reline.completion_proc = IRB::InputCompletor::CompletionProc @@ -398,7 +396,7 @@ def auto_indent(&block) mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt" message = "Press #{mod_key}+d to read the full document" contents = [message] + doc.accept(formatter).split("\n") - contents = contents.take(Reline.preferred_dialog_height) if Reline.respond_to?(:preferred_dialog_height) + contents = contents.take(Reline.preferred_dialog_height) y = cursor_pos_to_render.y Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49') @@ -455,11 +453,7 @@ def encoding def inspect config = Reline::Config.new str = "RelineInputMethod with Reline #{Reline::VERSION}" - if config.respond_to?(:inputrc_path) - inputrc_path = File.expand_path(config.inputrc_path) - else - inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') - end + inputrc_path = File.expand_path(config.inputrc_path) str += " and #{inputrc_path}" if File.exist?(inputrc_path) str end