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

Re: zle: vi mode: wrong undo handling on fresh lines

I sent this earlier but it hasn't arrived so resending. Sorry if it
appears twice.

"Jun T." wrote:
> This is my "trial" to (somewhat) improve the behavior of 'undo' after completion.
> The patch below is against (git-HEAD)+(patch in 32314 by Oliver Kiddle).

> The change in zle_tricky.c is to start a new undo-block when entering a
> completion.

I hate to be negative bit if we now split the undo block at all the
points where someone prefers it split. We'll end up back in the
situation Hauke Petersen complained about in September. It is also not
easy to recombine them. How about we instead add a split-undo zle
widget? It is then easy for someone to add that before completion or
other widgets like backward-delete-word.

I like the fact that a vi undo will now undo a whole change but I'm used
to using the emacs mode undo key to revert a completion. Also, as I
mentioned before, completion in vim doesn't split the undo.
> The change in zle_main.c is to make 'undo' no to bring back the suffix added
> by completion but erased when going back to the command mode.

I'm fairly convinced that we should handle the suffix with the simple
patch below. I've long had vi-cmd-mode set to first use
auto-suffix-retain. I could be wrong but would suspect most vi users
would prefer it this way. However, it'd be good to have the opinion of
another vi-mode user. What do you think?

> (This will also change the behavior in emacs-mode.)

I can't quite work out what the emacs-mode behaviour change is.


PS. I have now committed 32314. I've put some tests together but will
hold off on posting to them until we've finalised the behaviour. I
looked at merging Felix's zle tests but as he basically indicates in the
e-mail, he wasn't really finished. A number of his tests fail and I
haven't been able to work out why.

diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index 4372fe3..0e4c479 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -125,7 +125,7 @@
 "vi-change", vichange, 0
 "vi-change-eol", vichangeeol, 0
 "vi-change-whole-line", vichangewholeline, 0
-"vi-cmd-mode", vicmdmode, 0
+"vi-cmd-mode", vicmdmode, ZLE_KEEPSUFFIX
 "vi-delete", videlete, ZLE_KILL | ZLE_KEEPSUFFIX
 "vi-delete-char", videletechar, ZLE_KEEPSUFFIX
 "vi-digit-or-beginning-of-line", vidigitorbeginningofline, 0

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