Currently the tags will always get updated immediately when writing a
file. However, for large files that can slow down the writing process
noticeably, leading to annoying pauses. This commit instead defers the
updating process to the first CursorHold/CursorHoldI event after writing
a file, which should make the process much less noticeable.
Closes#289Closes#381
References SpaceVim/SpaceVim#129
When constructing the tag tree it is often necessary to look up tags
with a certain name and other attributes at the current depth. This was
previously done with the filter() function on the list of all the
relevant tags. However, this filtering is very slow.
This commit changes the FileInfo and TagInfo objects to save added tags
in a dictionary indexed by the name of the tag in addition to the list
(which is still maintained in parallel since it is necessary for things
like sorting). This significatly speeds up tag lookup since most tags
have unique names.
The current algorithm for contructing the tag tree works pretty well
even when pseudo-tags are encountered, but is quite complex, hard to
understand, and hard to tweak and optimize. This commit rewrites the
algorithm to a relatively straight-forward recursive algorithm that
makes use of placeholder pseudo-tags if required that will get replaced
if the actual tag is encountered later.
When switching buffers during the handling of the BufDelete event the
saved buffer number of the last alternate buffer will change, so we have
to save a local copy to be able to properly unset the 'tagbar_ignore'
buffer variable.
When opening the Tagbar window the window numbers can change so that
restoring the window history is not possible. Use the new window ID
functionality if it is available to make that possible.
When we have to go to the Tagbar window to update it the knowledge of
the previous window to the one we're coming from gets lost. Save it
before switching windows so we can restore it after returning from the
Tagbar window.
The QuitPre autocommand was introduced in Vim version 7.3.544. If Vim is
older than this then don't use the HandleOnlyWindow() functionality, so
in the case of closing the last window in a tab a user will have to
close the Tagbar window themselves.
This commit should (hopefully) finally fix the case of users calling
':bdelete/:bwipeout' or ':quit' while Tagbar is open and just do the
right thing. See commit e4cfe8a for a more thorough description of how
it's supposed to work.
When a window that is displaying a normal file gets closed with a :quit,
:bdelete or other command, Tagbar may end up as the only visible window
left, which isn't very useful. Previously Tagbar would just quit in such
a situation (unless there was more than one tab), but that is rather
non-intuitive.
The change in this commit introduces a mechanism that should hopefully
handle such a case properly based on which command was executed, and do
exactly what a user would expect:
- In the ':quit' case, it will close the current tabpage including
Tagbar unless it was the only tabpage, in which case it will quit Vim.
- In the ':bdelete/:bwipeout' case, it will delete the Tagbar buffer and
then reopen Tagbar once the buffer that Vim switched to is being
displayed.