Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: completion for parameter flags
On Sat, 4 Jun 2011 14:39:52 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> ${(<tab> shows me glob qualifiers.
> foo${(<tab> does nothing at all.
This exposed an existing bug, that "${(stuff) wasn't handled properly.
In a quoted string it needs to scan for untokenized parentheses.
Index: Completion/Zsh/Context/_brace_parameter
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_brace_parameter,v
retrieving revision 1.2
diff -p -u -r1.2 _brace_parameter
--- Completion/Zsh/Context/_brace_parameter 3 Jun 2011 22:06:59 -0000 1.2
+++ Completion/Zsh/Context/_brace_parameter 4 Jun 2011 21:19:17 -0000
@@ -4,7 +4,7 @@ local char delim found_percent found_m e
local -a flags
integer q_last n_q
-if [[ $PREFIX = '${('[^\)]# ]]; then
+if [[ $PREFIX = *'${('[^\)]# ]]; then
# Parameter flags.
compset -p 3
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.108
diff -p -u -r1.108 compcore.c
--- Src/Zle/compcore.c 3 Jun 2011 22:07:00 -0000 1.108
+++ Src/Zle/compcore.c 4 Jun 2011 21:19:17 -0000
@@ -1099,7 +1099,7 @@ mod_export char *
check_param(char *s, int set, int test)
{
char *p;
- int found = 0;
+ int found = 0, qstring = 0;
zsfree(parpre);
parpre = NULL;
@@ -1126,6 +1126,7 @@ check_param(char *s, int set, int test)
!(*p == String && p[1] == Snull) &&
!(*p == Qstring && p[1] == '\'')) {
found = 1;
+ qstring = (*p == Qstring);
break;
}
}
@@ -1161,7 +1162,8 @@ check_param(char *s, int set, int test)
/* Ignore the possible (...) flags. */
b++, br++;
- if (skipparens(Inpar, Outpar, &b) > 0) {
+ if ((qstring ? skipparens('(', ')', &b) :
+ skipparens(Inpar, Outpar, &b)) > 0) {
/*
* We are still within the parameter flags. There's no
* point trying to do anything clever here with
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author