Skip to content

Commit 08208ad

Browse files
authored
Fix display_document params in noautocomplete mode (#826)
* Fix display_document params in noautocomplete mode * Fix wrong preposing and target order in display_document The fixed wrong-ordered value is not used in RegexpCompletor, so this change does not affect the test.
1 parent 77ee59d commit 08208ad

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/irb/input-method.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,13 @@ def auto_indent(&block)
291291
@auto_indent_proc = block
292292
end
293293

294+
def retrieve_doc_namespace(matched)
295+
preposing, _target, postposing, bind = @completion_params
296+
@completor.doc_namespace(preposing, matched, postposing, bind: bind)
297+
end
298+
294299
def show_doc_dialog_proc
295-
doc_namespace = ->(matched) {
296-
preposing, _target, postposing, bind = @completion_params
297-
@completor.doc_namespace(preposing, matched, postposing, bind: bind)
298-
}
300+
input_method = self # self is changed in the lambda below.
299301
->() {
300302
dialog.trap_key = nil
301303
alt_d = [
@@ -311,7 +313,7 @@ def show_doc_dialog_proc
311313
cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
312314
return nil if result.nil? or pointer.nil? or pointer < 0
313315

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

@@ -419,8 +421,7 @@ def display_document(matched, driver: nil)
419421
return
420422
end
421423

422-
_target, preposing, postposing, bind = @completion_params
423-
namespace = @completor.doc_namespace(preposing, matched, postposing, bind: bind)
424+
namespace = retrieve_doc_namespace(matched)
424425
return unless namespace
425426

426427
driver ||= RDoc::RI::Driver.new

test/irb/test_input_method.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def setup
9090

9191
def display_document(target, bind)
9292
input_method = IRB::RelineInputMethod.new(IRB::RegexpCompletor.new)
93-
input_method.instance_variable_set(:@completion_params, [target, '', '', bind])
93+
input_method.instance_variable_set(:@completion_params, ['', target, '', bind])
9494
input_method.display_document(target, driver: @driver)
9595
end
9696

0 commit comments

Comments
 (0)