From caa1c38c6f0000b6ed6a6a50e8dca037ad82308a Mon Sep 17 00:00:00 2001 From: Marlon Richert Date: Fri, 5 May 2023 14:41:59 +0300 Subject: 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. --- Completion/Base/Core/_main_complete | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'Completion') diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index 169ca1f40..408a66ee3 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -93,19 +93,15 @@ fi if [[ -z "$compstate[quote]" ]]; then if [[ -o equals ]] && compset -P 1 '='; then compstate[context]=equal - elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then - if [[ "$PREFIX" = '~['[^\]]# ]]; then - # Inside ~[...] should be treated as a subscript. - compset -p 2 - # To be consistent, we ignore all but the contents of the square - # brackets. - compset -S '\]*' - compstate[context]=subscript - [[ -n $_comps[-subscript-] ]] && $_comps[-subscript-] && return - else - compset -p 1 - compstate[context]=tilde - fi + elif [[ "$PREFIX" = \~\[[^]]# ]]; then + # Inside ~[...] should be treated as a subscript. + compset -p 2 + # To be consistent, we ignore all but the contents of the square brackets. + compset -S '\]*' + compstate[context]=subscript + elif [[ "$PREFIX" = \~[^/]# ]]; then + compset -p 1 + compstate[context]=tilde fi fi -- cgit 1.4.1