From cd9e50c2cc64ea1fdefce9c803a89f37513ca2f1 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 3 Oct 2024 11:46:17 +0200 Subject: [PATCH] completions/set: Complete variables of all scopes when setting 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` 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. --- share/completions/set.fish | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/share/completions/set.fish b/share/completions/set.fish index 39e7a1b80..3fcf3ef03 100644 --- a/share/completions/set.fish +++ b/share/completions/set.fish @@ -102,15 +102,12 @@ set -l maybe_filter_private_vars ' echo "^__" 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: ')" -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; 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: ')" +# 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' -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' -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 -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 -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:\ )"