autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Fix incorrect logic around placing signs #1126

Closed martskins closed 3 years ago

martskins commented 3 years ago

This PR attempts to fix a bug around the logic on how we place the signs. The issue is described in #1125.

The fix I'm proposing simplifies a lot of the complexity around signs but could also be more expensive in some cases, as instead of calculating the signs diff and sending the signs to add and signs to delete, I propose just replacing the signs on the buffer with the new ones that fit in the current viewport. This is a pretty naive approach but I think we should favour correctness over performance.

I did, however, do what I mentioned in the issue: keep track of the viewport for each file and only update the signs when it has changed (except for cases like file changes when we really really want to update it, for which I added a force_redraw flag to the handle_cursor_moved function). I applied the same viewport logic to the section of handle_cursor_moved where we redraw virtual texts and highlights, so all this should also save us a lot of other updates to the buffer.

Kapture 2020-10-31 at 20 44 00

Fixes #1125 and #964