mirror of
https://github.com/zsh-users/zsh
synced 2024-09-16 06:30:26 +00:00
add _in_vared for completion inside vared; make insert-tab default to `false' there
This commit is contained in:
parent
6ba3ec5ec4
commit
1dc5677a41
|
@ -1,7 +1,7 @@
|
|||
DISTFILES_SRC='
|
||||
.distfiles
|
||||
_arg_compile _argument_sets _arguments _brace_parameter _combination
|
||||
_command_names _condition _default _describe _equal _first _jobs _math
|
||||
_parameter _precommand _redirect _regex_arguments _subscript _tilde
|
||||
_value _values
|
||||
_command_names _condition _default _describe _equal _first _in_vared
|
||||
_jobs _math _parameter _precommand _redirect _regex_arguments _subscript
|
||||
_tilde _value _values
|
||||
'
|
||||
|
|
28
Completion/Base/_in_vared
Executable file
28
Completion/Base/_in_vared
Executable file
|
@ -0,0 +1,28 @@
|
|||
#compdef -vared-
|
||||
|
||||
local also
|
||||
|
||||
# Completion inside vared.
|
||||
|
||||
if [[ $compstate[vared] = *\[* ]]; then
|
||||
# vared on an array-element
|
||||
compstate[parameter]=${compstate[vared]%%\[*}
|
||||
compstate[context]=-value-
|
||||
also=value
|
||||
else
|
||||
# vared on a parameter, let's see if it is an array
|
||||
compstate[parameter]=$compstate[vared]
|
||||
if [[ ${(tP)compstate[vared]} = *(array|assoc)* ]]; then
|
||||
compstate[context]=array_value
|
||||
also=-array-value-
|
||||
else
|
||||
compstate[context]=value
|
||||
also=-value-
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't insert TAB in first column. Never.
|
||||
|
||||
compstate[insert]="${compstate[insert]//tab /}"
|
||||
|
||||
_compalso "$also"
|
|
@ -1,13 +1,17 @@
|
|||
#autoload
|
||||
|
||||
# This searches $1 in the array for normal completions and calls the result.
|
||||
# This searches $* in the array for normal completions and calls the result.
|
||||
# It is used to include completions for another command or special context
|
||||
# into the list generated by the calling function.
|
||||
# For example the function for `-subscript-' could call this as in
|
||||
# `_compalso -math- "$@"' to get the completions that would be generated
|
||||
# for a mathematical context.
|
||||
# `_compalso -math-' to get the completions that would be generated for a
|
||||
# mathematical context.
|
||||
|
||||
local tmp
|
||||
local i tmp ret=1
|
||||
|
||||
tmp="$_comps[$1]"
|
||||
[[ -z "$tmp" ]] || "$tmp" "$@"
|
||||
for i; do
|
||||
tmp="$_comps[$1]"
|
||||
[[ -z "$tmp" ]] || "$tmp" && ret=0
|
||||
done
|
||||
|
||||
return ret
|
||||
|
|
|
@ -36,21 +36,7 @@ fi
|
|||
# If we are inside `vared' and we don't have a $compcontext, we treat
|
||||
# this like a parameter assignment. Which it is.
|
||||
|
||||
if [[ -n $compstate[vared] ]]; then
|
||||
if [[ $compstate[vared] = *\[* ]]; then
|
||||
# vared on an array-element
|
||||
compstate[parameter]=${compstate[vared]%%\[*}
|
||||
compstate[context]=value
|
||||
else
|
||||
# vared on a parameter, let's see if it is an array
|
||||
compstate[parameter]=$compstate[vared]
|
||||
if [[ ${(tP)compstate[vared]} = *(array|assoc)* ]]; then
|
||||
compstate[context]=array_value
|
||||
else
|
||||
compstate[context]=value
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
[[ -n $compstate[vared] ]] && compstate[context]=vared
|
||||
|
||||
# For arguments and command names we use the `_normal' function.
|
||||
|
||||
|
|
|
@ -35,8 +35,10 @@ typeset -U _lastdescr _comp_ignore
|
|||
|
||||
[[ -z "$curcontext" ]] && curcontext=:::
|
||||
|
||||
if [[ "$compstate[insert]" = tab* ]]; then
|
||||
zstyle -T ":completion:${curcontext}:" insert-tab && return 1
|
||||
if [[ "$compstate[insert]" = tab* && "$WIDGET" != *list* ]]; then
|
||||
{ zstyle -T ":completion:${curcontext}:" insert-tab &&
|
||||
{ [[ "$curcontext" != :* || -z "$compstate[vared]" ]] ||
|
||||
zstyle -t ":completion:vared${curcontext}:" insert-tab } } && return 1
|
||||
|
||||
compstate[insert]="${compstate[insert]//tab /}"
|
||||
fi
|
||||
|
|
|
@ -1258,7 +1258,8 @@ insert the TAB character if the completion code would normally do that
|
|||
(i.e. when there is no non-blank character to the left of the cursor
|
||||
yet). If set to `false', completion will be done even there.
|
||||
|
||||
The default value of this style is `true'.
|
||||
The default value of this style is `true' unless when completing
|
||||
inside the tt(vared) builtin command, where it defaults to `false'.
|
||||
)
|
||||
kindex(insert-unambiguous, completion style)
|
||||
item(tt(insert-unambiguous))(
|
||||
|
|
Loading…
Reference in a new issue