Closed orlp closed 3 years ago
In this plugin there's the following function that gets used to implement undo, plus one debug line I added.
function! repeat#wrap(command,count) let preserve = (g:repeat_tick == b:changedtick) call feedkeys((a:count ? a:count : '').a:command, 'n') exe (&foldopen =~# 'undo\|all' ? 'norm! zv' : '') if preserve let g:repeat_tick = b:changedtick endif echom g:repeat_tick b:changedtick preserve " Debug. endfunction
With some functions (I find it difficult to make a minimal reproducible example, it shows up in a plugin I'm making) that use cgn internally the feedkeys call in the above does not 'finish'. It's being lazy.
cgn
feedkeys
That means that
echom g:repeat_tick b:changedtick preserve " Debug.
prints something like 15 15 1, but manually inspecting b:changedtick again after the mapping has resolved gives 17.
15 15 1
b:changedtick
17
I fixed it in a local fork by changing
call feedkeys((a:count ? a:count : '').a:command, 'n')
to
call feedkeys((a:count ? a:count : '').a:command, 'nx')
to force the feedkeys call to do its work eagerly rather than lazily.
I don't know whether that negatively impacts others using this plugin, but for me it was necessary to get correct undo/redo behavior.
Oh, dupe of https://github.com/tpope/vim-repeat/issues/63#issue-323810749.
In this plugin there's the following function that gets used to implement undo, plus one debug line I added.
With some functions (I find it difficult to make a minimal reproducible example, it shows up in a plugin I'm making) that use
cgn
internally thefeedkeys
call in the above does not 'finish'. It's being lazy.That means that
prints something like
15 15 1
, but manually inspectingb:changedtick
again after the mapping has resolved gives17
.I fixed it in a local fork by changing
to
to force the
feedkeys
call to do its work eagerly rather than lazily.I don't know whether that negatively impacts others using this plugin, but for me it was necessary to get correct undo/redo behavior.