Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
On Mon, 2019-12-09 at 10:21 +0000, Peter Stephenson wrote:
> + for (ccount = 0, psrc = s, pdst = lpre;
> + ccount < lpl;
> + ++ccount, ++psrc, ++pdst)
> + {
> + if (*psrc == Dash)
> + *pdst = '-';
> + else
> + *pdst = *psrc;
> + }
This is a bit better thought through --- check if globbing is actually
in use and also beware of metafied characters.
pws
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index f242e1b28..1dcec387d 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -3178,7 +3178,27 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
/* Compute line prefix/suffix. */
lpl = offs;
lpre = zhalloc(lpl + 1);
- memcpy(lpre, s, lpl);
+ if (comppatmatch)
+ {
+ int ccount;
+ char *psrc, *pdst;
+ for (ccount = 0, psrc = s, pdst = lpre;
+ ccount < lpl;
+ ++ccount, ++psrc, ++pdst)
+ {
+ if (*psrc == Meta)
+ {
+ ccount++;
+ *pdst++ = *psrc++;
+ *pdst = *psrc;
+ } else if (*psrc == Dash)
+ *pdst = '-';
+ else
+ *pdst = *psrc;
+ }
+ }
+ else
+ memcpy(lpre, s, lpl);
lpre[lpl] = '\0';
qlpre = quotename(lpre);
lsuf = dupstring(s + offs);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author