summaryrefslogtreecommitdiff
path: root/Completion/Base/_value
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base/_value')
-rw-r--r--Completion/Base/_value8
1 files changed, 7 insertions, 1 deletions
diff --git a/Completion/Base/_value b/Completion/Base/_value
index 402bab236..15218eb60 100644
--- a/Completion/Base/_value
+++ b/Completion/Base/_value
@@ -2,10 +2,16 @@
_value () {
# You can customize completion for different parameters by writing a
- # function `_value:<name>'.
+ # function `_value:<name>', where <name> is the name of the parameter.
+ # When completing values of elements of associative arrays, we first
+ # search for a function `_value:<assoc>-<key>' and then for
+ # `_value:<assoc>', so it's simple to define different functions
+ # for different keys or one function for a whole association.
if (( $+functions[_value:$compstate[parameter]] )); then
"_value:$compstate[parameter]" "$@"
+ elif (( $+functions[_value:${compstate[parameter]%%-*}] )); then
+ "_value:${compstate[parameter]%%-*}" "$@"
elif [[ "$compstate[parameter]" != *-* &&
"${(Pt)${compstate[parameter]}}" = assoc* ]]; then
if (( CURRENT & 1 )); then