zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] fix completion of parameter names for ${<TAB> and ${(a)<TAB>
@ 2021-10-30  6:46 Jun. T
  2021-11-01  4:24 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Jun. T @ 2021-10-30  6:46 UTC (permalink / raw)
  To: zsh-workers

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))






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fix completion of parameter names for ${<TAB> and ${(a)<TAB>
  2021-10-30  6:46 [PATCH] fix completion of parameter names for ${<TAB> and ${(a)<TAB> Jun. T
@ 2021-11-01  4:24 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2021-11-01  4:24 UTC (permalink / raw)
  To: Jun. T; +Cc: Zsh hackers list

On Fri, Oct 29, 2021 at 11:47 PM Jun. T <takimoto-j@kba.biglobe.ne.jp> wrote:
>
> ${<TAB> works if '>=' is replaced by '>' at line 1192 of compcore.c
> (I think this is a simple off-by-one error).

That makes sense ... if the previous skipparens test was for <= this
on should be >.

> 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.

Thanks.  I think those lines were intended as an optimization but I
probably tested it only with completeinword and the cursor somewhere
other than at the end.

> 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.

I didn't find any.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-01  4:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-30  6:46 [PATCH] fix completion of parameter names for ${<TAB> and ${(a)<TAB> Jun. T
2021-11-01  4:24 ` Bart Schaefer

Code repositories for project(s) associated with this 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).