preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.13k stars 487 forks source link

New Option: g:tagbar_jump_lazy_scroll #703

Closed no-more-secrets closed 3 years ago

no-more-secrets commented 3 years ago

Currently when jumping to a tag, the buffer will always be scrolled to place the tag at the location dictated by g:tagbar_jump_offset. This means that if I jump to a tag that is already visible in the window (say, a few lines below my cursor) then the window will be scrolled unnecessarily, which can be a bit disorienting.

Solution: have a new option called g:tagbar_jump_lazy_scroll (defaults to 0) which, when turned on, will cause the following jump behavior:

  1. If the tag being jumped to is already visible in the window then just put the cursor on that line without scrolling the window.
  2. If the tag is not visible in the window, then perform the current jumping/scrolling behavior whereby the buffer is scrolled to put the tag/cursor on the line dictated by g:tagbar_jump_offset.

I think this would make for a smoother and more intuitive user experience.

raven42 commented 3 years ago

That seems like a good idea. I'm not sure how best to implement something like this though. Are there any vim options to do this?

no-more-secrets commented 3 years ago

I will submit a PR shortly.