-
-
Notifications
You must be signed in to change notification settings - Fork 84
Description
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):
vim -Nu NONE -S <(cat <<'EOF'
set rtp^=/path/to/vim-repeat
nno <c-b> xp:call repeat#set("\<lt>c-b>")<cr>
let buf =<< trim END
" fold A {{{1
" some text
" fold B {{{1
" some text
END
%d
pu!=buf
setl fdm=marker
EOF
) /tmp/file
- Press
zoto open the B fold. - Press
C-bto exchange the position of two characters and invokerepeat#set()which causes the wrapper mapping around the undo command to be installed. - Press
zcto close the B fold. - Press
kto move on the A fold. - Press
uto undo the last change.
Result: The A fold is opened.
Expected behavior
The B fold is opened.
Screenshots
Environment
- plugin version: c947ad2
- Vim version: 8.2 Included patches: 1-740
- OS: Ubuntu 16.04.6 LTS
- Terminal: XTerm(322)
Additional context
The issue is due to the zv command being executed too early:
vim-repeat/autoload/repeat.vim
Line 135 in c947ad2
| exe (&foldopen =~# 'undo\|all' ? 'norm! zv' : '') |
The 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 to feedkeys().
It's a regression introduced by 1b82cad.
