completions/set: Complete variables of all scopes when setting
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run

This was overly smart and tried to not show you e.g. global variables
unless you were setting without scope or explicitly global.

That is annoying when you do

`set -g fish_col<TAB>`

and don't get colors because they're universal, but you could
overwrite them.

We *could* elide e.g. local variables if we're setting a global, but I
can see someone wanting to set a universal variable on basis of a
global ("save this"), so I would rather not try to find the very
specific cases where this works.
This commit is contained in:
Fabian Boehm 2024-10-03 11:46:17 +02:00
parent 0fea1dae8c
commit cd9e50c2cc

View File

@ -102,15 +102,12 @@ set -l maybe_filter_private_vars '
echo "^__" echo "^__"
end end
)' )'
complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -l | $maybe_filter_private_vars | string replace ' ' \t'Local Variable: ')" # We do not *filter* these by the given scope because you might want to set e.g. a global to shadow a universal.
complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -g | $maybe_filter_private_vars | string replace -r '^((?:history|fish_killring) ).*' '$1' | string replace ' ' \t'Global Variable: ')" complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(set -l | $maybe_filter_private_vars | string replace ' ' \t'Local Variable: ')"
complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -U | $maybe_filter_private_vars | string replace ' ' \t'Universal Variable: ')" complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(set -g | $maybe_filter_private_vars | string replace -r '^((?:history|fish_killring) ).*' '$1' | string replace ' ' \t'Global Variable: ')"
complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(set -U | $maybe_filter_private_vars | string replace ' ' \t'Universal Variable: ')"
# Complete some fish configuration variables even if they aren't set. # Complete some fish configuration variables even if they aren't set.
complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(__fish_complete_special_vars)" complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(__fish_complete_special_vars)"
# Complete scope-specific variables
complete -c set -n '__fish_is_nth_token 1; and __fish_seen_argument -s l -l local' -x -a "(set -l | string replace ' ' \t'Local Variable: ')"
complete -c set -n '__fish_is_nth_token 1; and __fish_seen_argument -s g -l global' -x -a "(set -g | string replace ' ' \t'Global Variable: ')"
complete -c set -n '__fish_is_nth_token 1; and __fish_seen_argument -s U -l universal' -x -a "(set -U | string replace ' ' \t'Universal Variable: ')"
# Complete using preexisting variable names for `set --erase` # Complete using preexisting variable names for `set --erase`
complete -c set -n '__fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s U -s g -l local -l global -l Universal' -f -a "(set -g | string replace ' ' \tGlobal\ Variable:\ )" complete -c set -n '__fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s U -s g -l local -l global -l Universal' -f -a "(set -g | string replace ' ' \tGlobal\ Variable:\ )"