ZeroKnight/vim-signjump

Sign caching is imperfect

Closed this issue · 1 comments

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:

  1. Be in normal mode long enough that CursorHold is triggered. This causes a refresh of the buffer's sign cache.
  2. Disable GitGutter with :GitGutterDisable or :GitGutterToggle. GitGutter's signs disappear, but the sign cache is not updated to reflect this.
  3. 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

  1. 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?
  2. 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.
  3. Ask Bram to include an autocmd event for changes to signs
    • This would be the most ideal possible solution

For now, this plugin implements Solution 1: Build the sign list on each jump. Ditch the cache.