diff --git a/src/complete.cpp b/src/complete.cpp index 3898a0f81..67d1522d2 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -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)) { diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 28b1a3261..8ecb9f24f 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -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 '