Open lacygoill opened 4 years ago
There are several solutions, but I think the simplest one is to just pass zv to feedkeys().
Actually no, the simplest fix would be to use the t
flag: https://github.com/tpope/vim-repeat/pull/81#issuecomment-627657697
Edit: t
would cause the undo/redo command to be saved twice during a recording which is wrong. So, passing zv
to feedkeys()
is better.
Edit 2: Yes, but only on the condition that zv
is really needed; that is if the cursor is in a closed fold; otherwise, we may prevent u
, U
, and C-r
from printing some info about the undo state, as reported in #27. See this comment for more details.
Describe the bug
The undo command may open the wrong fold.
To Reproduce
Run this shell command (you'll need to update the path to the plugin):
zo
to open the B fold.C-b
to exchange the position of two characters and invokerepeat#set()
which causes the wrapper mapping around the undo command to be installed.zc
to close the B fold.k
to move on the A fold.u
to undo the last change.Result: The A fold is opened.
Expected behavior
The B fold is opened.
Screenshots
Environment
Additional context
The issue is due to the
zv
command being executed too early: https://github.com/tpope/vim-repeat/blob/c947ad2b6a16983724a0153bdf7f66d7a80a32ca/autoload/repeat.vim#L135The undo command is written in the typeahead via
feedkeys()
which doesn't execute it immediately. In contrast,zv
is executed via:norm
which does execute the command immediately. As a result,zv
is executed before the undo command, while it should be executed after.There are several solutions, but I think the simplest one is to just pass
zv
tofeedkeys()
.It's a regression introduced by https://github.com/tpope/vim-repeat/commit/1b82cad74cd5d5caf3c4092365cda54dc1fb853e.