DanilaMihailov / beacon.nvim

Whenever cursor jumps some distance or moves between windows, it will flash so you can see where it is
339 stars 9 forks source link

Jumping from the Quickfix List highlights the wrong position. #14

Open Remich opened 4 years ago

Remich commented 4 years ago

When the cursor is in the Quickfix List and then pressing enter on a entry in the Quickfix List often the wrong location is highlighted. Often it is the position of the previous jump from the Quickfix List to a location in a document, which is highlighted.

How to reproduce:

Have several locations in your Quickfix List. Quickfix LIst -> Enter -> New Location (1) -> Back to Quickfix List -> j -> Enter -> New Location (2); Now Location 1 is highlighted, but Location 2 should actually be highlighted.

Edit: Numbers. I did not intend to mention other issues.

DanilaMihailov commented 4 years ago

Yeah, I see that. Seems to be not working right when location from different file. Will look into it.

Thank you for feedback :)

TheBlob42 commented 2 years ago

I just discovered this great plugin recently and I really like its functionality, but this issue here also annoys me quite a bit :see_no_evil:

I think the issue here is in the order of how the code is evaluated:

I checked the current line (see here) when the function is executed and it is always the last cursor position in that window before the jump. My Vimscript knowledge is quite limited and I have no idea how to defer the highlight call to execute it after the jump was completed.

For Neovim I found a hacky solution that works for now (at least I haven't faced any issues yet):
(beacon.vim - line 295)

" replace this
silent autocmd WinEnter * call s:Highlight_position(v:false)
" with this
silent autocmd WinEnter * lua vim.schedule(function() vim.cmd('Beacon') end)

The vim.schedule function will defer the call on the event loop, so it is executed after the jump from the quickfix list is completed. Therefore the correct line is then extracted in beacon.nvim and the highlighting works. Unfortunately I have no idea how to transform this into a "general" solution working for Vim and Neovim :frowning_face: