1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-22 10:48:03 +02:00

51348: Fix subscript completion bugs inside ~[...]

When completing inside ~[...] (_with_ the trailing `]` present), the
following bugs occured:
- Subscript completion was skipped entirely when there were one or more
  slashes ('/') in the subscript, which is incorrect, since slashes are
  allowed there.
- Instead of going through _complete, $_comps[-subscript-] was called
  immediately, causing _setup to be skipped.
- If succesful, _main_complete was exited right after, causing
  menu-style, comppostfuncs and other essential completion features to
  be skipped.
This commit is contained in:
Marlon Richert 2023-05-05 14:41:59 +03:00 committed by Oliver Kiddle
parent 9a5f213573
commit caa1c38c6f
3 changed files with 26 additions and 16 deletions

View file

@ -1,5 +1,9 @@
2023-05-21 Oliver Kiddle <opk@zsh.org> 2023-05-21 Oliver Kiddle <opk@zsh.org>
* Marlon Richert: 51682: Completion/Base/Core/_main_complete,
Test/Y01completion.ztst: Fix subscript completion bugs
inside ~[...]
* Marlon Richert: 51759: Completion/Zsh/Type/_command_names: * Marlon Richert: 51759: Completion/Zsh/Type/_command_names:
Show alias values in command completions Show alias values in command completions

View file

@ -93,19 +93,15 @@ fi
if [[ -z "$compstate[quote]" ]]; then if [[ -z "$compstate[quote]" ]]; then
if [[ -o equals ]] && compset -P 1 '='; then if [[ -o equals ]] && compset -P 1 '='; then
compstate[context]=equal compstate[context]=equal
elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then elif [[ "$PREFIX" = \~\[[^]]# ]]; then
if [[ "$PREFIX" = '~['[^\]]# ]]; then # Inside ~[...] should be treated as a subscript.
# Inside ~[...] should be treated as a subscript. compset -p 2
compset -p 2 # To be consistent, we ignore all but the contents of the square brackets.
# To be consistent, we ignore all but the contents of the square compset -S '\]*'
# brackets. compstate[context]=subscript
compset -S '\]*' elif [[ "$PREFIX" = \~[^/]# ]]; then
compstate[context]=subscript compset -p 1
[[ -n $_comps[-subscript-] ]] && $_comps[-subscript-] && return compstate[context]=tilde
else
compset -p 1
compstate[context]=tilde
fi
fi fi
fi fi

View file

@ -75,17 +75,27 @@
>line: {: ~user2}{} >line: {: ~user2}{}
>line: {: ~user1}{} >line: {: ~user1}{}
comptesteval 'zsh_directory_name() { compadd "$expl[@]" -- name1 name2 }' comptesteval 'zsh_directory_name() { compadd "$expl[@]" -- name/1 name2 }'
comptest $': ~[\t\t\t\t' comptest $': ~[\t\t\t\t'
0:dynamic directory names after ~[ 0:dynamic directory names after ~[
>line: {: ~[name}{} >line: {: ~[name}{}
>line: {: ~[name}{} >line: {: ~[name}{}
>DESCRIPTION:{dynamically named directory} >DESCRIPTION:{dynamically named directory}
>NO:{name1} >NO:{name/1}
>NO:{name2} >NO:{name2}
>line: {: ~[name1]}{} >line: {: ~[name/1]}{}
>line: {: ~[name2]}{} >line: {: ~[name2]}{}
comptest $': ~[]\C-b\t\t\t\t'
0:dynamic directory names inside ~[...]
>line: {: ~[name}{]}
>line: {: ~[name}{]}
>DESCRIPTION:{dynamically named directory}
>NO:{name/1}
>NO:{name2}
>line: {: ~[name/1}{]}
>line: {: ~[name2}{]}
comptest $'echo ;:\C-b\C-b\t' comptest $'echo ;:\C-b\C-b\t'
0:directories and files before separator 0:directories and files before separator
>line: {echo }{;:} >line: {echo }{;:}