marks.nvim icon indicating copy to clipboard operation
marks.nvim copied to clipboard

Method 'refresh' breaks CursorHold

Open rodamaral opened this issue 2 years ago • 8 comments

This plugin is making my CursorHold autocmds never execute.

For example:

autocmd CursorHold <buffer> lua print'CursorHold'

This seems to happen due to M.refresh being called before my updatetime expires and then reseting the hold timer. https://github.com/chentau/marks.nvim/blob/f43e349601b439b4b07bec1d996cfd70d48d09fb/lua/marks/init.lua#L68

rodamaral avatar Nov 18 '21 15:11 rodamaral

One option would be to set ‘refresh_interval’ to some very high value so it won’t interfere, and the set up your own custom mark redraw logic on CursorHold. I’m traveling now but will post a snippet when I can

chentoast avatar Nov 19 '21 13:11 chentoast

I was wondering why my autosave suddenly stopped working.

mystilleef avatar Nov 21 '21 01:11 mystilleef

Can we switch to event autocmd WinScrolled to call refresh. I don't think the marks sign need update too offten @chentau

windwp avatar Dec 13 '21 07:12 windwp

WinScrolled is not enough. For things like mark preview, and extracting marks to loc/quickfix lists, we need the mark state to be synchronized even if they are not visible on screen. In addition, WinScrolled is not fired when switching buffers, which may happen when moving to bookmarks or capital marks.

Here's the workaround that I promised but never got around to posting:

lua <<EOF
require'marks'.setup {
  refresh_interval = 0 -- or some really large value to disable mark tracking
}
EOF

au CursorHold * lua require'marks'.refresh()

Note that whatever autocmd you choose is up to you; you can use WinScrolled instead if you want, for example.

chentoast avatar Dec 13 '21 17:12 chentoast

Ok i will do your solution to disable refresh. i notice your plugin force my status line redraw even i don't typing any key on normal mode.

windwp avatar Dec 14 '21 01:12 windwp

This is related https://neovim.discourse.group/t/psa-dont-rely-on-cursorhold-yet/1813

rodamaral avatar Jan 11 '22 17:01 rodamaral

FYI there has been a potential fix pushed to latest Neovim master. Would be great if people test this on latest HEAD to see if the issue still persists.

chentoast avatar Feb 06 '22 19:02 chentoast

I'm thinking of switching over to cursorhold as default in the next couple of weeks, but I don't want to break anyone's configuration. Does anyone have a timer-based approach or usage of the plugin that would not work with a cursorhold based refresh approach?

chentoast avatar Jul 31 '22 01:07 chentoast