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

Re: 'remove slash' bug



"Bart Schaefer" wrote:
> zsh% /usr/
> 
> Move the cursor to the 's'.  Press TAB.
> 
> 3.0.5	-->	/usr/
> 3.1.4	-->	/usr//

This seems to be trivial to fix, as appended (expect a couple of lines
of offset).  When it is, however, you get the other behaviour noted...

> I can't come up with any case that deletes anything other than slashes or
> spaces.  Here's how to get it to delete a space:
> 
> zsh% touch /tmp/foo
> zsh% ls /tm/foo
> 
> Move the cursor to the 'm' and press TAB.  In both 3.0.5 and 3.1.4, this
> produces "ls /tmp/foo " (note the trailing space).  In 3.1.4, typing any
> further key other than self-insert deletes the trailing space.  3.0.5
> leaves the space alone.

This seems to be standard behaviour in 3.1.4.  Just type `ls
/tmp/foo', hit tab, and you'll see the space is autoremovable anyway.
There is a quite deliberate test for this in the code at the moment,
so somebody (Zefram?) thought it was a good idea.  What should happen?

1 Present (3.1.4) behaviour
2 Space added, but left alone (not autoremovable)
  (i) if the cursor had to be moved to the end of the word
  (ii) even if the cursor was at the end of the word already
3 No space added if the cursor was previously not at the end of
the line, i.e. you would get /tmp/foo with the cursor immediately
after the foo.  In that case, another tab would add a space, although
with the /usr/ example you would get completion inside the directory
at that point (which you could with an autoremovable space, but less
intuitively).  In this case any space added could still be
  (i) autoremovable
  (ii) not

(Not adding any space ever is probably not sensible.)

All of these can readily be produced.  I presume 2(ii) was the
previous behaviour.

***************
*** 3441,3447 ****
  			fsuf, psuf);
  	    }
  	    /* And do the stat. */
! 	    if (!ztat(p, &buf, 0) && S_ISDIR(buf.st_mode)) {
  		/* It is a directory, so add the slash. */
  		havesuff = 1;
  		inststrlen("/", 1, 1);
--- 3442,3449 ----
  			fsuf, psuf);
  	    }
  	    /* And do the stat. */
! 	    if (p[strlen(p)-1] != '/' && !ztat(p, &buf, 0) &&
! 		S_ISDIR(buf.st_mode)) {
  		/* It is a directory, so add the slash. */
  		havesuff = 1;
  		inststrlen("/", 1, 1);

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy



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