mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-20 22:18:02 +02:00
Marlon Richert: 51861: fix _approximate when compadd has been overridden
Before this patch, if compadd had been overridden by a function of the same name, _approximate would not do corrections.
This commit is contained in:
parent
2a854aae48
commit
5f984319b5
2 changed files with 24 additions and 24 deletions
|
@ -1,5 +1,9 @@
|
||||||
2023-08-27 Bart Schaefer <schaefer@zsh.org>
|
2023-08-27 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* Marlon Richert: 51861 (tweaked for 52028):
|
||||||
|
Completion/Base/Completer/_approximate: allow _approximate
|
||||||
|
to provide corrections even when compadd is overridden
|
||||||
|
|
||||||
* 52028: Completion/Base/Utility/_shadow, Doc/Zsh/compsys.yo,
|
* 52028: Completion/Base/Utility/_shadow, Doc/Zsh/compsys.yo,
|
||||||
Doc/Zsh/contrib.yo, Functions/Misc/mkshadow: improve _shadow
|
Doc/Zsh/contrib.yo, Functions/Misc/mkshadow: improve _shadow
|
||||||
and _unshadow, add helper function and update documentation
|
and _unshadow, add helper function and update documentation
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
local _comp_correct _correct_expl _correct_group comax cfgacc match
|
local _comp_correct _correct_expl _correct_group comax cfgacc match
|
||||||
local oldcontext="${curcontext}" opm="$compstate[pattern_match]"
|
local oldcontext="${curcontext}" opm="$compstate[pattern_match]"
|
||||||
local dounfunction
|
|
||||||
integer ret=1
|
integer ret=1
|
||||||
|
|
||||||
if [[ "$1" = -a* ]]; then
|
if [[ "$1" = -a* ]]; then
|
||||||
|
@ -44,34 +43,31 @@ fi
|
||||||
|
|
||||||
_tags corrections original
|
_tags corrections original
|
||||||
|
|
||||||
# Otherwise temporarily define a function to use instead of
|
# Otherwise temporarily define a function to use instead of the builtin that
|
||||||
# the builtin that adds matches. This is used to be able
|
# adds matches. This is used to be able to stick the `(#a...)' in the right
|
||||||
# to stick the `(#a...)' in the right place (after an
|
# place (after an ignored prefix).
|
||||||
# ignored prefix).
|
|
||||||
#
|
#
|
||||||
# Current shell structure for use with "always", to make sure
|
# Current shell structure for use with "always", to make sure we unfunction our
|
||||||
# we unfunction the compadd.
|
# compadd and restore any compadd function defined previously.
|
||||||
{
|
{
|
||||||
if (( ! $+functions[compadd] )); then
|
_shadow -s _approximate compadd
|
||||||
dounfunction=1
|
compadd() {
|
||||||
compadd() {
|
local ppre="$argv[(I)-p]"
|
||||||
local ppre="$argv[(I)-p]"
|
|
||||||
|
|
||||||
[[ ${argv[(I)-[a-zA-Z]#U[a-zA-Z]#]} -eq 0 &&
|
[[ ${argv[(I)-[a-zA-Z]#U[a-zA-Z]#]} -eq 0 &&
|
||||||
"${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return
|
"${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return
|
||||||
|
|
||||||
if [[ "$PREFIX" = \~* && ( ppre -eq 0 || "$argv[ppre+1]" != \~* ) ]]; then
|
if [[ "$PREFIX" = \~* && ( ppre -eq 0 || "$argv[ppre+1]" != \~* ) ]]; then
|
||||||
PREFIX="~(#a${_comp_correct})${PREFIX[2,-1]}"
|
PREFIX="~(#a${_comp_correct})${PREFIX[2,-1]}"
|
||||||
else
|
else
|
||||||
PREFIX="(#a${_comp_correct})$PREFIX"
|
PREFIX="(#a${_comp_correct})$PREFIX"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(( $_correct_group && ${${argv[1,(r)-(|-)]}[(I)-*[JV]]} )) &&
|
(( $_correct_group && ${${argv[1,(r)-(|-)]}[(I)-*[JV]]} )) &&
|
||||||
_correct_expl[_correct_group]=${argv[1,(r)-(-|)][(R)-*[JV]]}
|
_correct_expl[_correct_group]=${argv[1,(r)-(-|)][(R)-*[JV]]}
|
||||||
|
|
||||||
builtin compadd "$_correct_expl[@]" "$@"
|
compadd@_approximate "$_correct_expl[@]" "$@"
|
||||||
}
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
_comp_correct=1
|
_comp_correct=1
|
||||||
|
|
||||||
|
@ -115,7 +111,7 @@ while [[ _comp_correct -le comax ]]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
} always {
|
} always {
|
||||||
[[ -n $dounfunction ]] && (( $+functions[compadd] )) && unfunction compadd
|
_unshadow
|
||||||
}
|
}
|
||||||
|
|
||||||
(( ret == 0 )) && return 0
|
(( ret == 0 )) && return 0
|
||||||
|
|
Loading…
Reference in a new issue