Repository navigation
Fix display_document params in noautocomplete mode - #826
Merged
Merged
Conversation
st0012
approved these changes
Dec 29, 2023
st0012
left a comment
Member
There was a problem hiding this comment.
Good catch 👍
Should we also add yamatanooroti tests for --noautocomplete cases?
Member
Author
|
It needs type-completor to test in rendering test. |
Member
|
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.
tompng
force-pushed
the
fix_display_document_params
branch
from
January 1, 2024 12:35
276758b to
29205ac
Compare
Member
Author
|
The suggested code looks better. Thanks👍 |
st0012
approved these changes
Jan 1, 2024
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Jan 1, 2024
(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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix destructuring completion params in display_document (only used in noautocomplete mode)
This bug only affects
irb --noautocomplete --type-completorbecause RegexpCompletor does not usepreposing.