From ae7b401029c959db817b6eaf66e155acdc77ec70 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 20 Oct 2024 07:09:54 +0200 Subject: [PATCH] completions/set: show innermost scope in variable description A side effect of cd9e50c2c (completions/set: Complete variables of all scopes when setting, 2024-10-03) is that HOME=$(mktemp -d) fish fish_config choose ayu\ Light set -S fish_color_ gives only completions that have the "Universal variable" description even though most colors are also defined in the global scope which usually takes precedence. Fix this by reordering the completions. (The last-added completion is shown first which is very surprising, we should change that). This is not perfect; if the user has already specified `-U`, then we should probably not show description of the global version. But that's still worth the trade that this commit makes. Finally, the description could show something like "Defined in universal and global scope" etc. --- share/completions/set.fish | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/completions/set.fish b/share/completions/set.fish index 3fcf3ef03..bf13908df 100644 --- a/share/completions/set.fish +++ b/share/completions/set.fish @@ -103,19 +103,19 @@ set -l maybe_filter_private_vars ' end )' # 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 -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 -l | $maybe_filter_private_vars | string replace ' ' \t'Local 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 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 -U | string replace ' ' \tUniversal\ 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:\ )" 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 -l | string replace ' ' \tLocal\ 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 -U | string replace ' ' \tUniversal\ Variable:\ )" # Complete scope-specific variables for `set --erase` -complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s g -l global' -f -a "(set -g | string replace ' ' \t'Global Variable: ')" complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s U -l universal' -f -a "(set -U | string replace ' ' \t'Universal Variable: ')" +complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s g -l global' -f -a "(set -g | string replace ' ' \t'Global Variable: ')" complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s l -l local' -f -a "(set -l | string replace ' ' \t'Local Variable: ')" # Color completions