zsh-workers
 help / color / mirror / code / Atom feed
* When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
@ 2019-12-09  1:19 Felix.Chen
  2019-12-09  9:23 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Felix.Chen @ 2019-12-09  1:19 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 206 bytes --]

% mkdir a-b

% touch a-b/{c,d}

 

Type 'ls a-b' without quotes and press tab multiple times, zsh will cycle
through 'ls a-b/c' and 'ls a-b/d'.

But if GLOB_COMPLETE is on, zsh only complete up to 'a-b/'.


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

* Re: When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
  2019-12-09  1:19 When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens Felix.Chen
@ 2019-12-09  9:23 ` Mikael Magnusson
  2019-12-09  9:29   ` Daniel Shahaf
  2019-12-10  0:51   ` Felix Chen
  0 siblings, 2 replies; 6+ messages in thread
From: Mikael Magnusson @ 2019-12-09  9:23 UTC (permalink / raw)
  To: Felix.Chen; +Cc: zsh-workers

On 12/9/19, Felix.Chen <felix.chen@3spocketnet.com.tw> wrote:
> % mkdir a-b
>
> % touch a-b/{c,d}
>
>
>
> Type 'ls a-b' without quotes and press tab multiple times, zsh will cycle
> through 'ls a-b/c' and 'ls a-b/d'.
>
> But if GLOB_COMPLETE is on, zsh only complete up to 'a-b/'.

Hi,

It works fine here, are you using an old version of zsh? (current
version is 5.7.1)

-- 
Mikael Magnusson

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

* Re: When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
  2019-12-09  9:23 ` Mikael Magnusson
@ 2019-12-09  9:29   ` Daniel Shahaf
  2019-12-09 10:21     ` Peter Stephenson
  2019-12-10  0:51   ` Felix Chen
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2019-12-09  9:29 UTC (permalink / raw)
  To: zsh-workers, Felix.Chen

Mikael Magnusson wrote on Mon, 09 Dec 2019 09:23 +00:00:
> On 12/9/19, Felix.Chen <felix.chen@3spocketnet.com.tw> wrote:
> > % mkdir a-b
> >
> > % touch a-b/{c,d}
> >
> >
> >
> > Type 'ls a-b' without quotes and press tab multiple times, zsh will cycle
> > through 'ls a-b/c' and 'ls a-b/d'.
> >
> > But if GLOB_COMPLETE is on, zsh only complete up to 'a-b/'.
> 
> Hi,
> 
> It works fine here, are you using an old version of zsh? (current
> version is 5.7.1)

I can reproduce it in 'zsh -f' + 'setopt GLOB_COMPLETE' but can't
reproduce it if I then run compinit, in current(ish) master.

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

* Re: When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
  2019-12-09  9:29   ` Daniel Shahaf
@ 2019-12-09 10:21     ` Peter Stephenson
  2019-12-09 10:34       ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2019-12-09 10:21 UTC (permalink / raw)
  To: zsh-workers

On Mon, 2019-12-09 at 09:29 +0000, Daniel Shahaf wrote:
> Mikael Magnusson wrote on Mon, 09 Dec 2019 09:23 +00:00:
> > 
> > On 12/9/19, Felix.Chen <felix.chen@3spocketnet.com.tw> wrote:
> > > 
> > > % mkdir a-b
> > > 
> > > % touch a-b/{c,d}
> > > 
> > > 
> > > 
> > > Type 'ls a-b' without quotes and press tab multiple times, zsh will cycle
> > > through 'ls a-b/c' and 'ls a-b/d'.
> > > 
> > > But if GLOB_COMPLETE is on, zsh only complete up to 'a-b/'.
> > Hi,
> > 
> > It works fine here, are you using an old version of zsh? (current
> > version is 5.7.1)
> I can reproduce it in 'zsh -f' + 'setopt GLOB_COMPLETE' but can't
> reproduce it if I then run compinit, in current(ish) master.

Presuming this is this issue...

There may be more like this, comptcl-age completion doesn't get much
attention.

pws

diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index f242e1b28..f86a7552c 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -3035,9 +3035,9 @@ sep_comp_string(char *ss, char *s, int noffs)
 static void
 makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
 {
-    int t, sf1, sf2, ooffs, um = usemenu, delit, oaw, gflags;
+    int t, sf1, sf2, ooffs, um = usemenu, delit, oaw, gflags, ccount;
     int mn = mnum, ohp = haspattern;
-    char *p, *sd = NULL, *tt, *s1, *s2, *os =  dupstring(s);
+    char *p, *sd = NULL, *tt, *s1, *s2, *os =  dupstring(s), *psrc, *pdst;
     struct cmlist ms;
 
     ccont |= (cc->mask2 & (CC_CCCONT | CC_DEFCONT | CC_PATCONT));
@@ -3178,7 +3178,15 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
     /* Compute line prefix/suffix. */
     lpl = offs;
     lpre = zhalloc(lpl + 1);
-    memcpy(lpre, s, lpl);
+    for (ccount = 0, psrc = s, pdst = lpre;
+	 ccount < lpl;
+	 ++ccount, ++psrc, ++pdst)
+    {
+	if (*psrc == Dash)
+	    *pdst = '-';
+	else
+	    *pdst = *psrc;
+    }
     lpre[lpl] = '\0';
     qlpre = quotename(lpre);
     lsuf = dupstring(s + offs);



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

* Re: When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
  2019-12-09 10:21     ` Peter Stephenson
@ 2019-12-09 10:34       ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2019-12-09 10:34 UTC (permalink / raw)
  To: zsh-workers

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



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

* RE: When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens
  2019-12-09  9:23 ` Mikael Magnusson
  2019-12-09  9:29   ` Daniel Shahaf
@ 2019-12-10  0:51   ` Felix Chen
  1 sibling, 0 replies; 6+ messages in thread
From: Felix Chen @ 2019-12-10  0:51 UTC (permalink / raw)
  To: zsh-workers

I found another glitch.
$ zsh --version
zsh 5.7.1 (x86_64-slackware-linux-gnu)
$ zsh -f
% setopt GLOB_COMPLETE
% unsetopt MENU_COMPLETE
% touch a-{b..d}
% ls a
Press tab twice, zsh should only complete up to 'a-' rather than inserting the first possible match.
cf.
% touch ee{f..h}
Is this related?


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

end of thread, other threads:[~2019-12-10  1:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09  1:19 When GLOB_COMPLETE is on, tab completion does not work with path containing hyphens Felix.Chen
2019-12-09  9:23 ` Mikael Magnusson
2019-12-09  9:29   ` Daniel Shahaf
2019-12-09 10:21     ` Peter Stephenson
2019-12-09 10:34       ` Peter Stephenson
2019-12-10  0:51   ` Felix Chen

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