* Oddity when completing option arguments after command arguments
@ 2017-12-18 12:01 Marko Myllynen
2017-12-20 4:52 ` dana
0 siblings, 1 reply; 3+ messages in thread
From: Marko Myllynen @ 2017-12-18 12:01 UTC (permalink / raw)
To: zsh-workers
Hi,
While working on some Zsh completions I happened to notice the following
when using this kind of completion (extracted ~minimal example follows):
#compdef foo
_foo () {
local curcontext="$curcontext" state line expl ret=1
declare -A opt_args
case $service in
foo)
_arguments -C -S -s \
"(- *)"{-h,--help}'[show help]' \
"(-h --help)"\*{-F+,--filename}'[specify filename]:file:_files' \
'*:host:_hosts' \
&& return 0
;;
esac
return ret
}
_foo "$@"
These work as expected:
$ foo -F <TAB> - getting filenames
$ foo -F<TAB> - getting filenames
$ foo <TAB> - getting hostnames
$ foo localhost --filename <TAB> - getting filenames
$ foo localhost -F<TAB> - getting filenames
But here's the unexpected case:
$ foo localhost -F <TAB> - getting filenames and hostnames
This is with 5.4.1. What could explain this behavior, any suggestions
how to fix this (so that in the last case would get only filenames)?
Thanks,
--
Marko Myllynen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Oddity when completing option arguments after command arguments
2017-12-18 12:01 Oddity when completing option arguments after command arguments Marko Myllynen
@ 2017-12-20 4:52 ` dana
2017-12-20 9:08 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2017-12-20 4:52 UTC (permalink / raw)
To: Marko Myllynen; +Cc: zsh-workers
On 18 Dec 2017, at 06:01, Marko Myllynen <myllynen@redhat.com> wrote:
>This is with 5.4.1. What could explain this behavior, any suggestions
>how to fix this (so that in the last case would get only filenames)?
I think this would do it?
I didn't test *super* extensively, but it seems to behave as expected in all of
the cases listed, and it passes the existing checks.
dana
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 71d61563b..0b1ba58dc 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2493,7 +2493,9 @@ ca_set_data(LinkList descr, LinkList act, LinkList subc,
* the case above right.
*/
if (arg->type == CAA_NORMAL &&
- opt && optdef && optdef->type == CAO_NEXT)
+ opt && optdef &&
+ (optdef->type == CAO_NEXT || optdef->type == CAO_ODIRECT ||
+ optdef->type == CAO_OEQUAL))
return;
if (single)
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index 7cbadfe8c..761b4b1d2 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -237,6 +237,27 @@
>NO:{-a}
>NO:{-b}
+ tst_arguments '*'{-x+,--xxx=}':optarg:(1)' '*:operand:(a)'
+ comptest $'tst \t'
+ comptest $'tst -x \t'
+ comptest $'tst -x\t'
+ comptest $'tst --xxx=\t'
+ comptest $'tst --xxx \t'
+ comptest $'tst a -x\t'
+ comptest $'tst a -x \t'
+ comptest $'tst a --xxx=\t'
+ comptest $'tst a --xxx \t'
+0:optarg completion following rest operand on line (workers/42141)
+>line: {tst a }{}
+>line: {tst -x 1 }{}
+>line: {tst -x1 }{}
+>line: {tst --xxx=1 }{}
+>line: {tst --xxx 1 }{}
+>line: {tst a -x1 }{}
+>line: {tst a -x 1 }{}
+>line: {tst a --xxx=1 }{}
+>line: {tst a --xxx 1 }{}
+
tst_arguments '-a' '*::rest:{compadd - -b}'
comptest $'tst arg -\t'
0:rest arguments
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Oddity when completing option arguments after command arguments
2017-12-20 4:52 ` dana
@ 2017-12-20 9:08 ` Peter Stephenson
0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2017-12-20 9:08 UTC (permalink / raw)
To: dana, zsh-workers
On Tue, 19 Dec 2017 22:52:29 -0600
dana <dana@dana.is> wrote:
> On 18 Dec 2017, at 06:01, Marko Myllynen <myllynen@redhat.com> wrote:
> >This is with 5.4.1. What could explain this behavior, any suggestions
> >how to fix this (so that in the last case would get only filenames)?
>
> I think this would do it?
>
> I didn't test *super* extensively, but it seems to behave as expected
> in all of the cases listed, and it passes the existing checks.
Thanks, that looks entirely plausible and this file is magic. I've
committed it.
pws
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-20 9:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-18 12:01 Oddity when completing option arguments after command arguments Marko Myllynen
2017-12-20 4:52 ` dana
2017-12-20 9:08 ` Peter Stephenson
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).