-
Notifications
You must be signed in to change notification settings - Fork 87
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
Refactor perform_completon #778
Conversation
d45c432
to
0a1e254
Compare
Flatten recursive method Remove CompletionState::COMPLETE
0a1e254
to
3a74d9b
Compare
|
||
unless Encoding.compatible?(target.encoding, item.encoding) | ||
# Crash with Encoding::CompatibilityError is required by readline-ext/test/readline/test_readline.rb | ||
# TODO: fix the test |
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.
Is the test still failing?
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.
Yes. here's the failed ci log https://github.com/tompng/reline/actions/runs/11743521493/job/32716559834
@@ -670,6 +670,19 @@ def self.vi_backward_word(line, byte_pointer) | |||
[byte_size, width] | |||
end | |||
|
|||
def self.common_prefix(list, ignore_case: false) |
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.
Just curious, what's the purpose of this method?
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.
Calculates the common prefix of the list
common_prefix(["a.singleton_class", "a.singleton_method", "a.singleton_methods"])
returns
the common part prefix "a.singleton_"
Used in TAB completion
$ irb --noautocomplete
irb(main):001> a=''
=> ""
irb(main):002> a.sin[TAB]
↓
irb(main):002> a.singleton_
complete_internal_proc
was doing this common prefix calculation (and also doing other things like filtering list and menu setup)
I split it to common_prefix
(Pure string processing logic independent to line_editor) and filter_normalize_candidates
(including completion logic).
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.
I understand. Thank you!
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.
LGTM~
(ruby/reline#778) Flatten recursive method Remove CompletionState::COMPLETE ruby/reline@aa5b278f3d
LineEditor#perform_completion
was complicated.When autocomplete is off, state is NORMAL, show_all_if_ambiguous is set, input is
1.ab[TAB]
It turned out that CompletionState::COMPLETION was not needed at all.
This pull request simplifies the flow.
Fixes tab completion with completion-ignore-case.
Unintentionally fixes bug related to the complex flow. Typing
1.ab[TAB][DELETE_CHAR_OR_LIST]
wrongly triggered show_document.