From: Marlon Richert <marlon.richert@gmail.com>
To: zsh-workers@zsh.org
Cc: Marlon Richert <marlon.richert@gmail.com>
Subject: [PATCH 3/3] Fix subscript completion bugs inside ~[...]
Date: Fri, 5 May 2023 14:41:59 +0300 [thread overview]
Message-ID: <20230505114154.76547-3-marlonrichert@users.noreply.github.com> (raw)
In-Reply-To: <CAH+w=7aWEesO_hN+eUCj9VCJ+soUvXqSSNRAAPSY-JoCZvcWcQ@mail.gmail.com>
From: Marlon Richert <marlon.richert@gmail.com>
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 +++++++++-------------
Test/Y01completion.ztst | 16 +++++++++++++---
2 files changed, 22 insertions(+), 16 deletions(-)
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
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 2524c43bd..693ea7d58 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -93,17 +93,27 @@
>line: {: ~user2}{}
>line: {: ~user1}{}
- comptesteval 'zsh_directory_name() { compadd "$expl[@]" -- name1 name2 }'
+ comptesteval 'zsh_directory_name() { compadd "$expl[@]" -- name/1 name2 }'
comptest $': ~[\t\t\t\t'
0:dynamic directory names after ~[
>line: {: ~[name}{}
>line: {: ~[name}{}
>DESCRIPTION:{dynamically named directory}
->NO:{name1}
+>NO:{name/1}
>NO:{name2}
->line: {: ~[name1]}{}
+>line: {: ~[name/1]}{}
>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'
0:directories and files before separator
>line: {echo }{;:}
--
2.39.2 (Apple Git-143)
next prev parent reply other threads:[~2023-05-05 11:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-29 18:07 Patch 1/3: Fix prefix insertion logic Marlon Richert
2023-04-29 18:08 ` Patch 2/3: Make dynamic dir completion easier to implement Marlon Richert
2023-04-29 18:09 ` Patch 3/3: Fix subscript completion bugs inside ~[...] Marlon Richert
2023-04-29 18:58 ` Patch 1/3: Fix prefix insertion logic Felipe Contreras
2023-04-29 19:02 ` Marlon Richert
2023-04-29 19:17 ` Bart Schaefer
2023-05-01 21:08 ` Aaron Schrab
2023-05-01 22:03 ` Bart Schaefer
2023-05-05 11:41 ` [PATCH 1/3] Fix _prefix " Marlon Richert
2023-06-07 6:03 ` Marlon Richert
2023-06-08 12:41 ` Jun. T
2023-06-15 14:11 ` Marlon Richert
2023-05-05 11:41 ` [PATCH 2/3] Make dynamic dir completion easier to implement Marlon Richert
2023-05-06 17:28 ` Bart Schaefer
2023-05-13 17:30 ` Bart Schaefer
2023-05-15 9:04 ` Oliver Kiddle
2023-05-05 11:41 ` Marlon Richert [this message]
2023-05-01 22:37 ` Patch 1/3: Fix prefix insertion logic Felipe Contreras
2023-05-01 22:52 ` Bart Schaefer
2023-05-02 4:49 ` Felipe Contreras
2023-05-02 19:16 ` Bart Schaefer
2023-05-02 20:14 ` Felipe Contreras
2023-05-05 11:51 ` Marlon Richert
2023-05-05 12:38 ` Felipe Contreras
2023-05-05 15:04 ` Mikael Magnusson
2023-05-06 17:23 ` Bart Schaefer
2023-05-01 23:36 ` Vin Shelton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230505114154.76547-3-marlonrichert@users.noreply.github.com \
--to=marlon.richert@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).