From 0fd09344c7b724a8573f4b487f4ed0e5365e237a Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Wed, 6 Nov 2013 17:06:39 +1300 Subject: [PATCH] Don't update during window opening, closes #179 Plugins like MiniBufExplorer can trigger an update before window initialization has finished, leading to errors. Skip processing until that is done. --- autoload/tagbar.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 8154da9..2dc99e2 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1733,8 +1733,10 @@ function! s:OpenWindow(flags) abort let s:window_expanded = 1 endif + let s:window_opening = 1 let openpos = g:tagbar_left ? 'topleft vertical ' : 'botright vertical ' exe 'silent keepalt ' . openpos . g:tagbar_width . 'split ' . '__Tagbar__' + unlet s:window_opening call s:InitWindow(autoclose) @@ -2915,7 +2917,7 @@ function! s:HighlightTag(openfolds, ...) abort let foldpat = '[' . s:icon_open . s:icon_closed . ' ]' let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\zs[^( ]\+\ze/' call s:LogDebugMessage("Highlight pattern: '" . pattern . "'") - if exists('g:syntax_on') " Safeguard in case syntax highlighting is disabled + if hlexists('TagbarHighlight') " Safeguard in case syntax highlighting is disabled execute 'match TagbarHighlight ' . pattern else execute 'match Search ' . pattern @@ -3196,6 +3198,15 @@ function! s:AutoUpdate(fname, force) abort " don't process it if exists('s:tagbar_qf_active') return + elseif exists('s:window_opening') + " This can happen if another plugin causes the active window to change + " with an autocmd during the initial Tagbar window creation. In that + " case InitWindow() hasn't had a chance to run yet and things can + " break. MiniBufExplorer does this, for example. Completely disabling + " autocmds at that point is also not ideal since for example + " statusline plugins won't be able to update. + call s:LogDebugMessage('Still opening window, stopping processing') + return endif " Get the filetype of the file we're about to process