zsh-workers
 help / color / mirror / code / Atom feed
* Re: 'remove slash' bug
@ 1998-06-21 18:01 Bart Schaefer
  0 siblings, 0 replies; 12+ messages in thread
From: Bart Schaefer @ 1998-06-21 18:01 UTC (permalink / raw)
  To: zsh-workers; +Cc: Timothy J Luoma

Way back on June 7, Timothy J. Luoma wrote:
} 
} ... there are times when I am in the middle of a path and do control-e  
} to get to the end of the line, and the / I put in (and wanted) is removed.

As a result of a side conversation with <tgape@cyberramp.net>, and further
evidenced by absence of the problem from both 3.1.4 and my locally-patched
3.0.5, I believe that the bug is fixed by this patch from PWS:

	http://www.zsh.org/mla/workers-1998-hyper/0106.html

It has to do with the way a dummy character is sometimes inserted and then
deleted when performing a completion within a word.  I didn't immediately
make the connection because the patch refers to expand-or-complete-prefix.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: 'remove slash' bug
  1998-06-16  5:21         ` Bart Schaefer
@ 1998-06-16  9:41           ` Peter Stephenson
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Stephenson @ 1998-06-16  9:41 UTC (permalink / raw)
  To: zsh-workers

"Bart Schaefer" wrote:
> On Jun 15,  6:35pm, Peter Stephenson wrote:
> } 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
> 
> I vote for (3i), if it's not hard to accomplish, simply because of being
> able to get completion inside the directory.

That's what I'd implemented, in fact, and decided I liked it that way,
too (for `end of the line', read `end of the word', however).  The
score is currently 2:0, so here's the patch.

This only has an effect when using completeinword and alwaystoend
together; if you complete inside a word and the cursor stays there,
you get a hard space, and if you complete at the end you get a soft
space.  I haven't changed those.  autoremoveslash is not relevant.

*** Src/Zle/zle_tricky.c.suf	Fri May  8 15:37:14 1998
--- Src/Zle/zle_tricky.c	Mon Jun 15 18:19:19 1998
***************
*** 3352,3358 ****
  	    menupos = wb;
  	} else
  	    menupos = cs;
! 	menuwe = (cs == we) || isset(ALWAYSTOEND);
  	menuend = we;
      }
      /* If we are already in a menu-completion or if we have done a *
--- 3352,3359 ----
  	    menupos = wb;
  	} else
  	    menupos = cs;
! 	/* menuwe == 2 means don't add space if no other suffix */
! 	menuwe = (cs == we) ? 1 : isset(ALWAYSTOEND) ? 2 : 0;
  	menuend = we;
      }
      /* If we are already in a menu-completion or if we have done a *
***************
*** 3470,3476 ****
  	    if(menuwe && isset(AUTOPARAMKEYS))
  		suffixlen[','] = suffixlen['}'] = 1;
  	}
!     } else if(!menucmp && !havesuff) {
  	/* If we didn't add a suffix, add a space, unless we are *
  	 * doing menu completion.                                */
  	inststrlen(" ", 1, 1);
--- 3472,3478 ----
  	    if(menuwe && isset(AUTOPARAMKEYS))
  		suffixlen[','] = suffixlen['}'] = 1;
  	}
!     } else if(!menucmp && !havesuff && menuwe != 2) {
  	/* If we didn't add a suffix, add a space, unless we are *
  	 * doing menu completion.                                */
  	inststrlen(" ", 1, 1);

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


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

* Re: 'remove slash' bug
  1998-06-15 16:35       ` Peter Stephenson
@ 1998-06-16  5:21         ` Bart Schaefer
  1998-06-16  9:41           ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 1998-06-16  5:21 UTC (permalink / raw)
  To: Peter Stephenson, zsh-workers

On Jun 15,  6:35pm, Peter Stephenson wrote:
} Subject: Re: 'remove slash' bug
}
} "Bart Schaefer" wrote:
} > 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.
} 
} 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

I vote for (3i), if it's not hard to accomplish, simply because of being
able to get completion inside the directory.

As a general rule, I'd prefer that zsh didn't auto-remove anything it
didn't auto-insert in the first place, except possibly upon accept-line,
but that's probably hard to keep track of.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: 'remove slash' bug
  1998-06-14 21:16     ` Bart Schaefer
  1998-06-15  6:49       ` Mircea Damian
@ 1998-06-15 16:35       ` Peter Stephenson
  1998-06-16  5:21         ` Bart Schaefer
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 1998-06-15 16:35 UTC (permalink / raw)
  To: zsh-workers

"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@ibmth.df.unipi.it>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


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

* Re: 'remove slash' bug
  1998-06-15  6:49       ` Mircea Damian
@ 1998-06-15 16:34         ` Timothy J Luoma
  0 siblings, 0 replies; 12+ messages in thread
From: Timothy J Luoma @ 1998-06-15 16:34 UTC (permalink / raw)
  To: Mircea Damian; +Cc: zsh-workers

	Author:        Mircea Damian <dmircea@mail.kappa.ro>
	Original-Date: Mon, 15 Jun 1998 09:49:27 +0300
	Message-ID:    <19980615094927.A24448@mail.kappa.ro>

> There is another thing which puzzles me.
> Try to type for example:
> cd /usr/loca/bin
> then go somewhere over "loca" and press TAB. It would normally complete
> "loca" to "local" and then it would go to the end of the command... but it
> doesn't! it just goes at the end leaving the command untouched.
>
> Is this ok? Am I missing something?

I am running 3.1.4 and find this strange also:

$ ls -1d /usr/lo*
/usr/local
/usr/log

(so "/usr/loc" should be enough to be unique)

$ cd /usr/loca/bin

left-arrow over to between the "c" and "a" in "loca" and hit tab -- NOTHING.

left-arrow over to between the "a" and "/" in "loca/bin" and hit tab --  
completed to the end and cursor goes to the end of "/bin/"

Shouldn't the cursor between the "c" and the "a" be enough?

TjL



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

* Re: 'remove slash' bug
  1998-06-14 21:16     ` Bart Schaefer
@ 1998-06-15  6:49       ` Mircea Damian
  1998-06-15 16:34         ` Timothy J Luoma
  1998-06-15 16:35       ` Peter Stephenson
  1 sibling, 1 reply; 12+ messages in thread
From: Mircea Damian @ 1998-06-15  6:49 UTC (permalink / raw)
  To: Bart Schaefer, zsh-workers

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

On Sun, Jun 14, 1998 at 02:16:38PM -0700, Bart Schaefer wrote:
> 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.

There is another thing which puzzles me.
Try to type for example:
cd /usr/loca/bin
then go somewhere over "loca" and press TAB. It would normally complete
"loca" to "local" and then it would go to the end of the command... but it
doesn't! it just goes at the end leaving the command untouched.

Is this ok? Am I missing something?

PS: I'm using zsh-3.0.5!

-- 
Mircea Damian
Network Manager
dmircea@roedu.net, dmircea@lbi.ro, dmircea@kappa.ro
MD65-RIPE, MD2225, MD1-6BONE
Phone: +40-1-4115246

[-- Attachment #2: Type: application/pgp-signature, Size: 248 bytes --]

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

* Re: 'remove slash' bug
  1998-06-14 13:56   ` TGAPE!
@ 1998-06-14 21:16     ` Bart Schaefer
  1998-06-15  6:49       ` Mircea Damian
  1998-06-15 16:35       ` Peter Stephenson
  0 siblings, 2 replies; 12+ messages in thread
From: Bart Schaefer @ 1998-06-14 21:16 UTC (permalink / raw)
  To: zsh-workers

On Jun 14,  1:56pm, TGAPE! wrote:
} Subject: Re: 'remove slash' bug
}
} Wayne Davison wrote:
} > 
} > Timothy J Luoma writes:
} >> However, there are times when I am in the middle of a path and do
} >> control-e to get to the end of the line, and the / I put in (and
} >> wanted) is removed.
} > 
} > I haven't managed to reproduce this problem, but I have been meaning
} > to look into a problem with the yank command being used right after
} > an auto-added slash.  I think the yank should leave the slash there
} 
} I can reproduce it.  Type
} 
} /usr<left to u><tab><control-e>

Hm.  What you describe isn't quite the same thing, but I think I've
finally got the original complaint figured out, based on what you say.

In order for the effect to happen, you must have all of autoremoveslash,
alwaystoend, and completeinword set.  Starting with this:

zsh% /usr/

Move the cursor to the 's'.  Press TAB.

3.0.5	-->	/usr/
3.1.4	-->	/usr//

In both cases, the cursor is at the end of the string.  Any following
key other than one bound to self-insert will delete the slash that is
immediately before the cursor.  In 3.1.4, this still leaves the original
slash behind, but it was wrong to have inserted a second slash in the
first place.  In 3.0.5, this (incorrectly?) deletes the only slash.

This also works starting with (say) /u/ or /us/, with the cursor on the
second slash or the 's'.

On Jun 14,  1:56pm, TGAPE! wrote:
} Subject: Re: 'remove slash' bug
}
} This is actually a more general problem, because it doesn't have to be a
} slash character which gets deleted.  It'll be whatever would be deleted
} with a backspace.

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.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: 'remove slash' bug
  1998-06-08  3:56 ` Wayne Davison
@ 1998-06-14 13:56   ` TGAPE!
  1998-06-14 21:16     ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: TGAPE! @ 1998-06-14 13:56 UTC (permalink / raw)
  To: zsh-workers

Wayne Davison wrote:
> 
> Timothy J Luoma writes:
>> However, there are times when I am in the middle of a path and do
>> control-e to get to the end of the line, and the / I put in (and
>> wanted) is removed.
> 
> I haven't managed to reproduce this problem, but I have been meaning
> to look into a problem with the yank command being used right after
> an auto-added slash.  I think the yank should leave the slash there,
> but perhaps it should be made to depend on what text is being yanked
> (i.e.  make it work just like the yanked text had been typed).

I can reproduce it.  Type

/usr<left to u><tab><control-e>

This is actually a more general problem, because it doesn't have to be a
slash character which gets deleted.  It'll be whatever would be deleted
with a backspace.

I saw this quite some time ago, but was too busy to submit a full
trouble report.  I'm running 3.1.1; I've seen it with 3.1.2 and 3.0.5.
(No, I can't remember why I backed out of 3.1.2, yes, I do feel it's
time to upgrade.)

Ed


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

* Re: 'remove slash' bug
  1998-06-07 22:41 Timothy J Luoma
  1998-06-08  0:22 ` Bart Schaefer
@ 1998-06-08  3:56 ` Wayne Davison
  1998-06-14 13:56   ` TGAPE!
  1 sibling, 1 reply; 12+ messages in thread
From: Wayne Davison @ 1998-06-08  3:56 UTC (permalink / raw)
  To: Timothy J Luoma; +Cc: zsh-workers

Timothy J Luoma writes:
> However, there are times when I am in the middle of a path and do
> control-e to get to the end of the line, and the / I put in (and
> wanted) is removed.

I haven't managed to reproduce this problem, but I have been meaning
to look into a problem with the yank command being used right after
an auto-added slash.  I think the yank should leave the slash there,
but perhaps it should be made to depend on what text is being yanked
(i.e.  make it work just like the yanked text had been typed).

..wayne..


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

* Re: 'remove slash' bug
  1998-06-08  0:22 ` Bart Schaefer
@ 1998-06-08  0:53   ` Timothy J Luoma
  0 siblings, 0 replies; 12+ messages in thread
From: Timothy J Luoma @ 1998-06-08  0:53 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

	Author:        "Bart Schaefer" <schaefer@brasslantern.com>
	Original-Date: Sun, 7 Jun 1998 17:22:01 -0700
	Message-ID:    <980607172202.ZM30640@candle.brasslantern.com>

> I can't get that to happen, either in 3.0.5 nor in 3.1.4.  Can you explain
> in more detail the steps that you take and the options that you have set?

No, I can never reproduce it... just every now and again I go "Hey, what  
happened to the / I had there?"

Probably some form of pilot error... don't sweat it

TjL



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

* Re: 'remove slash' bug
  1998-06-07 22:41 Timothy J Luoma
@ 1998-06-08  0:22 ` Bart Schaefer
  1998-06-08  0:53   ` Timothy J Luoma
  1998-06-08  3:56 ` Wayne Davison
  1 sibling, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 1998-06-08  0:22 UTC (permalink / raw)
  To: Timothy J Luoma, zsh-workers

On Jun 7,  6:41pm, Timothy J Luoma wrote:
} Subject: 'remove slash' bug
}
} I've got the option set to that a trailing / will be removed

That's only supposed to happen when the slash was appended as the result
of doing a file completion.  It's not supposed to happen to slashes that
you type explicitly.

} However, there are times when I am in the middle of a path and do control-e  
} to get to the end of the line, and the / I put in (and wanted) is removed.

I can't get that to happen, either in 3.0.5 nor in 3.1.4.  Can you explain
in more detail the steps that you take and the options that you have set?


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* 'remove slash' bug
@ 1998-06-07 22:41 Timothy J Luoma
  1998-06-08  0:22 ` Bart Schaefer
  1998-06-08  3:56 ` Wayne Davison
  0 siblings, 2 replies; 12+ messages in thread
From: Timothy J Luoma @ 1998-06-07 22:41 UTC (permalink / raw)
  To: zsh-workers


I can never get this to happen when I want it to.

I've got the option set to that a trailing / will be removed

However, there are times when I am in the middle of a path and do control-e  
to get to the end of the line, and the / I put in (and wanted) is removed.

Maybe an example is better:

say I have this line, and the cursor is the _

# echo /something/really/long_

and then I move the cursor here

# echo /something/_really/long

and make it

# echo /something/very/really/long

with the cursor between the / and the r in really and then do control-e to  
goto the end of the line and it becomes

# echo /something/veryreally/long

Is that a bug of some sort or just what happens with that feature turned on ?



TjL






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

end of thread, other threads:[~1998-06-21 18:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-21 18:01 'remove slash' bug Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
1998-06-07 22:41 Timothy J Luoma
1998-06-08  0:22 ` Bart Schaefer
1998-06-08  0:53   ` Timothy J Luoma
1998-06-08  3:56 ` Wayne Davison
1998-06-14 13:56   ` TGAPE!
1998-06-14 21:16     ` Bart Schaefer
1998-06-15  6:49       ` Mircea Damian
1998-06-15 16:34         ` Timothy J Luoma
1998-06-15 16:35       ` Peter Stephenson
1998-06-16  5:21         ` Bart Schaefer
1998-06-16  9:41           ` Peter Stephenson

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