Jumping from the Quickfix List highlights the wrong position.
Remich opened this issue · 2 comments
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.
Yeah, I see that. Seems to be not working right when location from different file. Will look into it.
Thank you for feedback :)
I just discovered this great plugin recently and I really like its functionality, but this issue here also annoys me quite a bit 🙈
I think the issue here is in the order of how the code is evaluated:
- press enter in qf window
- cursor jumps to the new window
- WinEnter event is executed --> current line is highlighted
- cursor is actually moved inside the window to the target destination
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