preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.09k stars 484 forks source link

Moving the cursor sometimes clears the selection #833

Closed fidelski closed 1 year ago

fidelski commented 1 year ago

Thanks for this plugin, it rocks for me! Really nice outline, I love it!

Just one issue: sometimes, when I move the cursor around, my selection gets cleared. For instance, if I move the cursor a line up and then select the whole line, the selection immediately disappears and I have to re-select the line.

tagbar-clears-selection

I assume this is due to some autocmd on CursorHold or because of the setting concerning sorting (I've set g:tagbar_sort = 0) but to be honest I have no idea.

My settings for Tagbar:

let g:tagbar_sort = 0
let g:tagbar_compact = 1
let g:tagbar_autopreview = 0
let g:tagbar_show_data_type = 1
let g:tagbar_width = 50

Any idea how I could get this behavior fixed?

raven42 commented 1 year ago

Hmm... I haven't seen this behavior before. I am not able to reproduce this either even when using the same configurations you've listed above. I also tried playing around with other values or configuration settings and still have not been able to reproduce this.

Are you able to confirm this is indeed the Tagbar plugin that is causing this behavior? Have you tried disabling all other plugins and leaving only Tagbar enabled and then are you still seeing this behavior?

fidelski commented 1 year ago

The thing is that this does not happen when Tagbar is closed. It only happens when the Tagbar is opened. But I will try to disable other plugins and check.

fidelski commented 1 year ago

The problem occurs by the combination of antoinemadec/FixCursorHold.nvim and Tagbar. As I have just seen the FixCursorHold Plugin will be unnecessary starting with neovim 0.8. But currently for me the plugin is necessary because otherwise things like vim.lsp.buf.document_highlight do not work in CursorHold. The FixCursorHold even mentions Tagbar in the sense that it improves snappiness. I don't know what exactly causes the issue but it seems that there is something done in some CursorHold that results in a cleared selection. I also cannot state whether it is an issue caused by Tagbar or by FixCursorHold.

raven42 commented 1 year ago

Hmm. Ok we might need someone more familiar with FixCursorHold or neovim in general. I don't use either unfortuantely. If you want to take a crack at it @fidelski we can help facilitate a pull request.

fidelski commented 1 year ago

I can confirm that the issue is gone with the current nightly build of neovim (NVIM v0.8.0-dev-1132-g37a71d1f2) and not using the FixCursorHold plugin (as it states that it will be unnecessary). So this issue can be closed, sorry for the noise.