-
Notifications
You must be signed in to change notification settings - Fork 121
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
Should we also add yamatanooroti tests for --noautocomplete
cases?
It needs type-completor to test in rendering test. |
I'd avoid mutating internal states for tests as they're bound with deep implementation details. diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index b74974b..573b6da 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -291,11 +291,12 @@ module IRB
@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)
- }
->() {
dialog.trap_key = nil
alt_d = [
@@ -311,7 +312,7 @@ module IRB
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 = retrieve_doc_namespace(result[pointer])
# Use first one because document dialog does not support multiple namespaces.
name = name.first if name.is_a?(Array)
@@ -419,8 +420,7 @@ module IRB
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 |
The fixed wrong-ordered value is not used in RegexpCompletor, so this change does not affect the test.
276758b
to
29205ac
Compare
The suggested code looks better. Thanks👍 |
(ruby/irb#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. ruby/irb@08208adb5e
Fix destructuring completion params in display_document (only used in noautocomplete mode)
This bug only affects
irb --noautocomplete --type-completor
because RegexpCompletor does not usepreposing
.