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

Re: some more problems with delete-whole-word-match, no patch

On Fri, 9 Nov 2007 16:56:56 +0100
"Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
> 1)
> if you have two or more spaces between two words and position the
> cursor between them, invoking the widget will insert an extra space.
> 2)
> if you position the cursor at the end of the word, the widget leaves
> the last character of the word intact, if there is a trailing space
> (as there usually is if the word isn't the last word on the command
> line).

(You mean with the cursor on the whitespace itself.)

> Putting in a [[ $pos1 = $pos2 ]] && return seems to fix the first
> problem but I figured the problems are probably related somehow, and
> I'm not sure why the second occurs.

You're right, it's the same bug.  If there's whitespace at the cursor
position it gets the end position one too short.

Index: Functions/Zle/delete-whole-word-match
RCS file: /cvsroot/zsh/zsh/Functions/Zle/delete-whole-word-match,v
retrieving revision 1.5
diff -u -r1.5 delete-whole-word-match
--- Functions/Zle/delete-whole-word-match	10 Nov 2007 17:37:55 -0000	1.5
+++ Functions/Zle/delete-whole-word-match	10 Nov 2007 18:52:58 -0000
@@ -31,7 +31,7 @@
 if [[ -n "${matched_words[4]}" ]]; then
     # There's whitespace at the cursor position, so only delete
     # up to the cursor position.
-    pos2=$CURSOR
+    (( pos2 = CURSOR + 1 ))
     # No whitespace at the cursor position, so delete the
     # current character and any following wordcharacters.

Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

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