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

Re: bug in replace-string: widget loses characters



On 8 October 2012 19:19, Moritz Bunkus <moritz@xxxxxxxxxx> wrote:
> zsh 5.0.0 on Arch Linux here. I'm using the replace-string widget and
> have the problem that often it loses characters from the current input
> when I use it. Not always, but often enough.
>
> In order to demonstrate what I mean, do the following:
>
> * Start zsh with --no-rcs:
>
> sweet-chili% zsh --no-rcs
> sweet-chili% zsh --version
> zsh 5.0.0 (x86_64-unknown-linux-gnu)
>
> * load the widget and bind it to a key, e.g. Alt-R:
>
> sweet-chili% autoload replace-string
> sweet-chili% zle -N replace-regex replace-string
> sweet-chili% bindkey '^[r' replace-regex
>
> * Next enter some text with several arguments, don't hit enter. In
> this example I've used the following:
>
> sweet-chili% somecmd 64/ubuntu/precise 64/ubuntu/quantal argab
>
> * Hit Alt-R. Replace 64 with 32, and the result will be:
>
> sweet-chili% somecmd 32/ubuntu/precise 32/ubuntu/quantal arga

Good news! Your problem is now officially classified as "weird".
(To be honest, "weird and interesting" is the one to go for,
but we're half way there.)

I think it's a problem with "undo".  After the function has read the
original and replacement strings from the area under the command line,
it's supposed to undo all that, so that you don't see it as part of the
normal undo history (undo should take you back through the replacement,
then immediately back through any changes you made before invoking the
replace widget).  It looks like that undo can go one change too far,
which means I've got the counting of undo changes wrong somewhere.

I didn't really properly get to grips with the undo system,
so this isn't that surprising. I suppose it's no use hoping
anybody else is going to understand it.  I'll take a look
later.

Anyway, it's not a problem with the function itself; you could work
around it by removing the "zle undo" line, which will expose the
previous unhelpful undo behaviour of the replacement widgets but
should mean the replacement itself works OK.

pws



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