zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: bug in replace-string: widget loses characters
Date: Tue, 9 Oct 2012 12:22:58 +0100	[thread overview]
Message-ID: <CAECNH1TwZO8ZMZE2jB4G7e03yTA+qXbtKioWKK8xzH4n-9OucA@mail.gmail.com> (raw)
In-Reply-To: <CANPayMTaAjtWV6=CE1rAuMhbZX=igKtBwNBLysPBq-W+G_GJYQ@mail.gmail.com>

On 8 October 2012 19:19, Moritz Bunkus <moritz@bunkus.org> 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


  reply	other threads:[~2012-10-09 11:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08 18:19 Moritz Bunkus
2012-10-09 11:22 ` Peter Stephenson [this message]
2012-10-09 11:54   ` Moritz Bunkus
2012-10-09 14:34   ` Peter Stephenson
2012-10-09 15:24     ` Bart Schaefer
2012-10-09 15:44       ` Peter Stephenson
2012-10-09 16:11         ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAECNH1TwZO8ZMZE2jB4G7e03yTA+qXbtKioWKK8xzH4n-9OucA@mail.gmail.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).