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

Re: completion ( compctl ) does not trigger for command names containing dashes



On Wed, May 3, 2023 at 2:59 AM Fredrik Ax <fredrik@xxxxxxxx> wrote:
>
> zshprompt% compctl -k '(arg1 arg2 arg3)' with-dash
>
> # typing 'with-dash ' and hitting [Tab] once:
> zshprompt% with-dash
> file2.txt    myfile1.txt

This dates back to the tokenization of hyphens to fix bugs in [a-z]
types of patterns.  The ancient code in compctl is using the raw
command string and therefore looking for completions for
$'with\233-dash' rather than 'with-dash'.

See if this (attached) fixes it without breaking anything else.
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 690cf6efb..6ceb5d87f 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1315,6 +1315,8 @@ get_comp_string(void)
 	    ins = (tok == REPEAT ? 2 : (tok != STRING && tok != TYPESET));
 	    zsfree(cmdstr);
 	    cmdstr = ztrdup(tokstr);
+	    untokenize(cmdstr);
+	    remnulargs(cmdstr);
 	    cmdtok = tok;
 	    /*
 	     * If everything before is a redirection, or anything


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