undotree icon indicating copy to clipboard operation
undotree copied to clipboard

When Undotree window is open, executing macro with a count causes multiple changes

Open Asheq opened this issue 5 years ago • 12 comments

Steps to reproduce

  1. Open Undotree window with :UndotreeShow
  2. Type qq to record macro in register q
  3. Type othis is a test<Esc>q to type text in a new line and stop recording macro
  4. Type 5@q to execute macro 5 times.

Actual: Five new changes are added to the undo list Expected: One change is added to the undo list (this is how it works when the Undotree window is closed)

Video: example

Asheq avatar Jan 09 '20 20:01 Asheq

this is interesting. Looks like some of the auto commands might changed the undo behaviour. btw, thanks for the video! it's super easy to repro the issue on my side thanks to it.

mbbill avatar Jan 10 '20 00:01 mbbill

Was this ever resolved? I am seeing this is on nvim 0.10 nightly with latest undo tree.

MXfive avatar May 03 '24 08:05 MXfive

Was this ever resolved? I am seeing this is on nvim 0.10 nightly with latest undo tree.

it's not

mbbill avatar May 06 '24 21:05 mbbill

Any idea what mere the issue might be? Interesting in having a stab at this at some point. Currently having to restart without Undotree loaded when I want to run macros like this.

MXfive avatar May 07 '24 02:05 MXfive

initially I think it might due to some autocommands that triggered a undo node creation, like exiting/entering insertion mode will do that. But that's only when the undotree panel is open. If you have to disable the plugin then I believe something else is wrong because when undotree panel is not open the auto commands shouldn't be registered. Do you mind check the auto commands by running :au BufEnter or simply :au while the undotree panel is not open, and check if there's anything related to undotree?

mbbill avatar May 07 '24 08:05 mbbill

Nothing that could be related to undotree on BufEnter for my setup:

--- Autocommands ---
FileExplorer  BufEnter
*sil call s:LocalBrowse(expand("<amatch>"))
lualine  BufEnter
*lua require'lualine.components.branch.git_branch'.find_git_dir()
lua require'lualine.components.diff.git_diff'.update_diff_args()
lualine_stl_refresh  BufEnter
*call v:lua.require'lualine'.refresh({'kind': 'tabpage', 'place': ['statusline'], 'trigger': 'autocmd'})
treesitter_context_update  BufEnter
*<Lua 204: ~/.local/share/nvim/lazy/nvim-treesitter-context/lua/treesitter-context.lua:21>

MXfive avatar May 07 '24 08:05 MXfive

yeah it looks normal. so you're having this issue without opening the undotree panel right?

mbbill avatar May 07 '24 08:05 mbbill

Actually I just realized I don't have this same issue as OP. OP was talking about undo tree being open in a single buffer. My issue is actually when repeating a macro over multiple files. I'll write up a proper issue for you later with repro steps for that. Basically doing something like argdo normal @q on a list of files only works for the first one, then after that Undotree gets opened and the macro isn't executed properly on the remaining files.

MXfive avatar May 07 '24 08:05 MXfive

undotree gets opened? is there any hotkey that opens the panel getting accidently recorded?

mbbill avatar May 07 '24 08:05 mbbill

undotree gets opened? is there any hotkey that opens the panel getting accidently recorded?

Yes it was being opened. Was able to reproduce reliably. Was just doing a find and replace of an array attribute across multiple files. Undotree did not open while recording the macro, nor while manually replaying it. But it did when using :argdo ...

MXfive avatar May 07 '24 08:05 MXfive

that's interesting...

mbbill avatar May 07 '24 08:05 mbbill

Not sure what happened, but now I am really unable to reproduce it..

MXfive avatar May 08 '24 02:05 MXfive