completions: don't treat token at cursor as flag

This commit is contained in:
Johannes Altmanninger 2024-07-20 13:06:24 +02:00
parent a35c3d4d10
commit 6feec60a8e
6 changed files with 7 additions and 7 deletions

View File

@ -16,7 +16,7 @@ end
# Returns 0 if we're after `env` and all previous tokens have not yet contained an equal sign
# Prevents `env` completions from completing payload completions.
function __fish_env_not_yet_vars
not string match -qe = (commandline -c)
not string match -qe -- = (commandline -c)
end
# Generate a list of possible variable names to redefine, excluding any already redefined.
@ -43,7 +43,7 @@ end
# Generate a list of possible completions for the current variable name from history
function __fish_env_values_from_history
string match -rq "(?<name>.+)=(?<value>.*)" (commandline -ct); or return 1
string match -rq -- "(?<name>.+)=(?<value>.*)" (commandline -ct); or return 1
# Caveat lector: very crude multi-word tokenization handling below!
set -l rname (string escape --style=regex -- $name)

View File

@ -37,7 +37,7 @@ end
#
# Inherit user/host completions from ssh
complete -c scp -d Remote -n "__fish_no_scp_remote_specified; and not string match -e : (commandline -ct)" -a "(complete -C'ssh ' | string replace -r '\t.*' ':')"
complete -c scp -d Remote -n "__fish_no_scp_remote_specified; and not string match -e -- : (commandline -ct)" -a "(complete -C'ssh ' | string replace -r '\t.*' ':')"
# Local path
complete -c scp -d "Local Path" -n "not string match @ -- (commandline -ct)"

View File

@ -5,7 +5,7 @@ set -l runtime userparameter_reload \
log_level_decrease=
function __fish_string_in_command -a ch
string match -rq $ch (commandline)
string match -rq -- $ch (commandline)
end
function __fish_prepend -a prefix

View File

@ -9,7 +9,7 @@ set -l runtime config_cache_reload \
log_level_decrease=
function __fish_string_in_command -a ch
string match -rq $ch (commandline)
string match -rq -- $ch (commandline)
end
function __fish_prepend -a prefix

View File

@ -21,7 +21,7 @@ set -l runtime config_cache_reload \
set -l scope rwlock mutex processing
function __fish_string_in_command -a ch
string match -rq $ch (commandline)
string match -rq -- $ch (commandline)
end
function __fish_prepend -a prefix

View File

@ -30,7 +30,7 @@ function __npm_filtered_list_packages
end
# Do not provide any completions if nothing has been entered yet to avoid long hang.
if string match -rq . (commandline -ct)
if string match -rq -- . (commandline -ct)
# Filter the results here rather than in the C++ code due to #5267
# `all-the-package-names` reads a billion line JSON file using node (slow) then prints
# it all (slow) using node (slow). Directly parse the `names.json` file that ships with it instead.