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

Fix display_document params in noautocomplete mode #826

Merged
merged 2 commits into from
Jan 1, 2024
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
15 changes: 8 additions & 7 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,13 @@ def auto_indent(&block)
@auto_indent_proc = block
end

def retrieve_doc_namespace(matched)
preposing, _target, postposing, bind = @completion_params
@completor.doc_namespace(preposing, matched, postposing, bind: bind)
end

def show_doc_dialog_proc
doc_namespace = ->(matched) {
preposing, _target, postposing, bind = @completion_params
@completor.doc_namespace(preposing, matched, postposing, bind: bind)
}
input_method = self # self is changed in the lambda below.
->() {
dialog.trap_key = nil
alt_d = [
Expand All @@ -311,7 +313,7 @@ def show_doc_dialog_proc
cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
return nil if result.nil? or pointer.nil? or pointer < 0

name = doc_namespace.call(result[pointer])
name = input_method.retrieve_doc_namespace(result[pointer])
# Use first one because document dialog does not support multiple namespaces.
name = name.first if name.is_a?(Array)

Expand Down Expand Up @@ -419,8 +421,7 @@ def display_document(matched, driver: nil)
return
end

_target, preposing, postposing, bind = @completion_params
namespace = @completor.doc_namespace(preposing, matched, postposing, bind: bind)
namespace = retrieve_doc_namespace(matched)
return unless namespace

driver ||= RDoc::RI::Driver.new
Expand Down
2 changes: 1 addition & 1 deletion test/irb/test_input_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def setup

def display_document(target, bind)
input_method = IRB::RelineInputMethod.new(IRB::RegexpCompletor.new)
input_method.instance_variable_set(:@completion_params, [target, '', '', bind])
input_method.instance_variable_set(:@completion_params, ['', target, '', bind])
input_method.display_document(target, driver: @driver)
end

Expand Down