Sign caching is imperfect
ZeroKnight opened this issue · 1 comments
ZeroKnight commented
The current method of relying on an autocmd to refresh the buffer's cache (b:signjump_signs
) of signs is flawed. While the current list of events to trigger on covers a lot of cases, there are still edge cases that cannot be easily covered.
For example, this scenario with GitGutter:
- Be in normal mode long enough that
CursorHold
is triggered. This causes a refresh of the buffer's sign cache. - Disable GitGutter with
:GitGutterDisable
or:GitGutterToggle
. GitGutter's signs disappear, but the sign cache is not updated to reflect this. - Try to jump to the next/previous sign. Vim will throw an error for trying to jump to a non-existent sign because the cache is stale.
Possible Solutions
- Ditch the autocmd and simply build the sign list on each jump.
- I worry that this will see performance hits on buffers with a great enough number of signs. Is this something that could occur outside of rare occasions, though?
- On top of the existing autocmd events, add a global timer that periodically refreshes the cache in the background.
- This is obviously prone to race conditions and would likely be doing unnecessary work most of the time.
- Ask Bram to include an autocmd event for changes to signs
- This would be the most ideal possible solution
ZeroKnight commented
For now, this plugin implements Solution 1: Build the sign list on each jump. Ditch the cache.