-
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
append completion_append_character only when continous completion is … #764
append completion_append_character only when continous completion is … #764
Conversation
lib/reline/line_editor.rb
Outdated
@@ -866,7 +868,7 @@ def editing_mode | |||
@completion_state = CompletionState::PERFECT_MATCH | |||
end | |||
return if result.nil? | |||
target, preposing, completed, postposing = result | |||
target, preposing, completed, postposing, continuable = result |
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.
continuable
in calculated twice.
One in complete_internal_proc(list.count > 1
) and other in this method
if list.one?
@completion_state = CompletionState::PERFECT_MATCH
How about using the condition @completion_state != CompletionState::PERFECT_MATCH
instead of continuable, or set a local variable inside if list.one?
if list.one?
@completion_state = CompletionState::PERFECT_MATCH
perfect_matched_and_need_to_perform_append_char = true # FIXME: shorter name
end
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.
Thanks for your suggestion! But consider this case when list
is something like:
['foo', 'foo_bar']
When we input foo_[tab]
, it will be completed to foo_bar
. A completion char should be appended but currently this case will be marked as MENU_WITH_PERFECT_MATCH
. That's why I separately check list.count
instead of inside if list.one?
case.
After reconsideration, I think maybe it's OK to treat the above case as a PERFECT_MATCH
?
(For demonstration I made the changes anyway. Looking forward to you comment! )
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.
Treating it as PERFECT_MATCH makes sense to me 👍
lib/reline/line_editor.rb
Outdated
@buffer_of_lines[@line_index] = (preposing + completed + completion_append_character.to_s + postposing).split("\n")[@line_index] || String.new(encoding: @encoding) | ||
line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n")[@line_index] || String.new(encoding: @encoding) | ||
unless just_show_list | ||
_completion_append_character = continuable ? '' : completion_append_character.to_s |
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.
Underscore prefixed local variable represents unused variable. Ruby itself won't show unused variable warning if the unused variable starts with _. If it is used, it is better not start with _.
How about just append_character
or completed += completion_append_character.to_s unless continuable
The change looks good. Could you resolve conflicts? |
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.
Thank you 👍
Fix #754. Insert
completion_append_character
only when there is no more possible completion