Fix completions if previous arg is a variable

complete -C'echo $HOM ' would complete $HOM instead of a new token.
Fixes another regression introduced in
6fb7f9b6b - Fix completion for builtins with subcommands
This commit is contained in:
Johannes Altmanninger
2020-01-18 20:20:22 +01:00
parent 1643df0d23
commit b18f605e4f
2 changed files with 7 additions and 2 deletions

View File

@@ -1502,8 +1502,10 @@ void completer_t::perform() {
// If we are completing a variable name or a tilde expansion user name, we do that and return.
// No need for any other completions.
const wcstring current_token = cur_tok.get_source(cmd);
if (try_complete_variable(current_token) || try_complete_user(current_token)) {
return;
if (cur_tok.location_in_or_at_end_of_source_range(cursor_pos)) {
if (try_complete_variable(current_token) || try_complete_user(current_token)) {
return;
}
}
if (cmd_tok.location_in_or_at_end_of_source_range(cursor_pos)) {

View File

@@ -165,3 +165,6 @@ end
complete -c complete_test_function_desc -xa '(complete -Csome_function)'
complete -C'complete_test_function_desc ' | count
# CHECK: 1
complete -c prev-arg-variable -f
complete -C'prev-arg-variable $HOME '