-
Notifications
You must be signed in to change notification settings - Fork 86
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -838,7 +838,9 @@ def editing_mode | |
end | ||
result | ||
} | ||
[target, preposing, completed, postposing] | ||
|
||
continuable = list.count > 1 | ||
[target, preposing, completed, postposing, continuable] | ||
end | ||
|
||
private def perform_completion(list, just_show_list) | ||
|
@@ -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 | ||
return if completed.nil? | ||
if target <= completed and (@completion_state == CompletionState::COMPLETION) | ||
if list.include?(completed) | ||
|
@@ -881,9 +883,10 @@ def editing_mode | |
@completion_state = CompletionState::MENU | ||
perform_completion(list, true) if @config.show_all_if_ambiguous | ||
end | ||
if not just_show_list and target < completed | ||
@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 commentThe 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 _. |
||
@buffer_of_lines[@line_index] = (preposing + completed + _completion_append_character + postposing).split("\n")[@line_index] || String.new(encoding: @encoding) | ||
line_to_pointer = (preposing + completed + _completion_append_character).split("\n")[@line_index] || String.new(encoding: @encoding) | ||
@byte_pointer = line_to_pointer.bytesize | ||
end | ||
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.
continuable
in calculated twice.One in complete_internal_proc(
list.count > 1
) and other in this methodHow about using the condition
@completion_state != CompletionState::PERFECT_MATCH
instead of continuable, or set a local variable insideif list.one?
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:When we input
foo_[tab]
, it will be completed tofoo_bar
. A completion char should be appended but currently this case will be marked asMENU_WITH_PERFECT_MATCH
. That's why I separately checklist.count
instead of insideif 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 👍