Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug in ZSH's vi emulation
On Wed, 02 Nov 2016 21:12:43 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Nov 2, 5:51pm, Oliver Kiddle wrote:
> }
> } We've also got a separate issue of only lastchar being stuffed into
> } vichgbuf so repeating, e.g. gU doesn't work. Why is keybuflen only
> } 1 in startvichange? That, along with what the general point of lastchar
> } is, has me fairly puzzled.
>
> It's because of getkeymapcmd():
>
> if(lastlen != keybuflen) {
> unmetafy(keybuf + lastlen, &keybuflen); <-- here
> ungetbytes(keybuf+lastlen, keybuflen);
> if(vichgflag)
> vichgbufptr -= keybuflen;
> keybuf[lastlen] = 0;
> }
>
> Seems like it ought to do the following? Or else use a temporary instead
> of stomping on keybuflen.
>
> diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
> index 3db4207..b5244b5 100644
> --- a/Src/Zle/zle_keymap.c
> +++ b/Src/Zle/zle_keymap.c
> @@ -1622,7 +1622,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
> ungetbytes(keybuf+lastlen, keybuflen);
> if(vichgflag)
> vichgbufptr -= keybuflen;
> - keybuf[lastlen] = 0;
> + keybuf[keybuflen = lastlen] = 0;
> }
> *funcp = func;
> *strp = str;
>
Yes, I stared at this for a while but I think the intention is to take
the (keybuflen-lastlen) null-terminated characters off the end and make
them available for re-reading as input, leaving only the first lastlen
in the key buffer.
That means keybuflen needs updating at the end anyway, to get rid of
those characters from the key buffer, so use of a temporary is
immaterial.
Comments when this was originally written probably wouldn't have hurt.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author