Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Reline 0.3.6 or higher #632

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion irb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 3 additions & 9 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the removal of this check has broken IRB's autocomplete for me. I'm getting an error saying undefined method preferred_dialog_height' for Reline:Module`.

~/Code/springboard $ irb
irb(main):001:0> select/Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb/input-method.rb:399:in `block in <class:RelineInputMethod>': undefined method `preferred_dialog_height' for Reline:Module (NoMethodError)
                 select                    █
      contents = contents.take(Reline.preferred_dialog_height)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:588:in `instance_exec'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:588:in `call'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:623:in `call'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:776:in `update_each_dialog'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:652:in `block in render_dialog'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:650:in `map'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:650:in `render_dialog'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/line_editor.rb:500:in `rerender'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:356:in `block (3 levels) in inner_readline'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:354:in `each'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:354:in `block (2 levels) in inner_readline'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:429:in `block in read_io'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:399:in `loop'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:399:in `read_io'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:352:in `block in inner_readline'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:350:in `loop'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:350:in `inner_readline'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:278:in `block in readmultiline'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/ansi.rb:149:in `block in with_raw_input'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/ansi.rb:149:in `raw'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline/ansi.rb:149:in `with_raw_input'
	from /Users/brianmcgue/.gem/gems/reline-0.3.6/lib/reline.rb:274:in `readmultiline'
	from /Users/brianmcgue/.rbenv/versions/3.2.0/lib/ruby/3.2.0/forwardable.rb:240:in `readmultiline'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb/input-method.rb:413:in `gets'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:540:in `block (2 levels) in eval_input'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:764:in `signal_status'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:539:in `block in eval_input'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb/ruby-lex.rb:220:in `readmultiline'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb/ruby-lex.rb:246:in `block in each_top_level_statement'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb/ruby-lex.rb:245:in `loop'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb/ruby-lex.rb:245:in `each_top_level_statement'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:558:in `eval_input'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:494:in `block in run'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:493:in `catch'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:493:in `run'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/lib/irb.rb:416:in `start'
	from /Users/brianmcgue/.gem/gems/irb-1.7.2/exe/irb:9:in `<top (required)>'
	from /Users/brianmcgue/.gem/bin/irb:25:in `load'
	from /Users/brianmcgue/.gem/bin/irb:25:in `<main>'

This is confirmed if I reopen IRB:

irb(main):001:0> Reline.respond_to?(:preferred_dialog_height)
=> false

My apologies if this isn't the way correct manner to bring up issues. Would you like me to create an issue in the repo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the trouble, the issue has been addressed in #638

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have checked the issues first!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. Thanks for raising the issue!

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')
Expand Down Expand Up @@ -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
Expand Down