diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 09b6888..1da6055 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -582,8 +582,6 @@ function! s:CreateAutocommands() abort autocmd CursorHoldI * call \ s:AutoUpdate(fnamemodify(expand(''), ':p'), 0) endif - autocmd BufDelete,BufWipeout * - \ nested call s:HandleBufDelete(expand(''), expand('')) " Suspend Tagbar while grep commands are running, since we don't want " to process files that only get loaded temporarily to search them @@ -596,6 +594,15 @@ function! s:CreateAutocommands() abort endif augroup END + " Separate these autocmds out from the others as we want to always perform + " these actions even if the tagbar window closes. + augroup TagbarCleanupAutoCmds + if !g:tagbar_no_autocmds + autocmd BufDelete,BufWipeout * + \ nested call s:HandleBufDelete(expand(''), expand('')) + endif + augroup END + let s:autocommands_done = 1 endfunction