preservim / tagbar

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

Tagbar messes up identation on long function names and fields #784

Closed daedroza closed 2 years ago

daedroza commented 3 years ago

When tagbar_wrap is set to 1 with linebreak, tagbar_wrap messes up indentation. A screenshot can be found here.

The only way to mitigate this issue is to set nolinebreak, however setting this from global init.vimrc is not a complete solution as people might want linebreak as well.

raven42 commented 2 years ago

This is occurring with very large tags that exceed the available space on the tagbar window. It is part of the vim wrap with linebreak functionality and is unavoidable when both these options are set.

As per original implementation of the g:tagbar_wrap feature in #659 there was no explicit call to do a setlocal linebreak. However if this is set by the user via a set linebreak, then the tagbar window will inherit this setting.

This could be a point of contention how the user prefers to see the wrap occur. In some cases using the linebreak option to only allow breaking at words makes it much easier to read. Contrary to this, if the user has a lot of very long tags that cause a wrap, then it will look weird. Unfortunately there is not a way to break on words after the first one, so the tag word is being pushed to the wrapped line causing this display issue.

To fix this, it will probably be best to allow the user to control it via the g:tagbar_wrap configuration with an additional value to explicitly control the linebreak functionality.

raven42 commented 2 years ago

Pushed up #785 as a potential fix for this. @daedroza can you try it out and let me know if this looks like it will work for your needs?

daedroza commented 2 years ago

Tested with tagbar_wrap = 2. It works as intended!