Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] fix completion of parameter names for ${<TAB> and ${(a)<TAB>



With current git master, nothing is offered by
  ${<TAB>
  ${(a)<TAB>
although ${a<TAB> offers parameter names starting with 'a'.

git-bisect showed that the problem started with

commit d0e071c5f0bf6a879756f72e1f0d0ae6952a4b49
Author: Bart Schaefer
Date:   Sat May 15 13:40:37 2021 -0700

    48790: COMPLETE_IN_WORD inside brace-param


${<TAB> works if '>=' is replaced by '>' at line 1192 of compcore.c
(I think this is a simple off-by-one error). But ${(a)<TAB> still
doesn't work. In the patch below I removed the lines 1203-1209
(and the use of the variable 'tb' that is now redundant) to fix
this problem. The original problem (worker/48788⁩) that is fixed by
the above commit is not affected by this patch. I _hope_ there are
no bad side effects.


diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 63136854e..9ec48f367 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1187,9 +1187,9 @@ check_param(char *s, int set, int test)
 		return NULL;
 
 	    /* Ignore the possible (...) flags. */
-	    tb = ++b, br++;
-	    if ((qstring ? skipparens('(', ')', &tb) :
-		 skipparens(Inpar, Outpar, &tb)) > 0 || tb - s >= offs) {
+	    b++, br++;
+	    if ((qstring ? skipparens('(', ')', &b) :
+		 skipparens(Inpar, Outpar, &b)) > 0 || b - s > offs) {
 		/*
 		 * We are still within the parameter flags.  There's no
 		 * point trying to do anything clever here with
@@ -1200,14 +1200,6 @@ check_param(char *s, int set, int test)
 		ispar = 2;
 		return NULL;
 	    }
-	    if ((qstring ? '(' : Inpar) == *b) {
-		/*
-		 * We are inside the braces but on the opening paren.
-		 * There is nothing useful to complete here?
-		 */
-		return NULL;
-	    } else
-		b = tb;	/* Skip over the flags */
 
 	    for (tb = p - 1; tb > s && *tb != Outbrace && *tb != Inbrace; tb--);
 	    if (tb > s && *tb == Inbrace && (tb[-1] == String || *tb == Qstring))








Messages sorted by: Reverse Date, Date, Thread, Author