Permalink
Browse files

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.
  • Loading branch information...
1 parent abffaba commit 0fd09344c7b724a8573f4b487f4ed0e5365e237a @majutsushi committed Nov 6, 2013
Showing with 12 additions and 1 deletion.
  1. +12 −1 autoload/tagbar.vim
View
@@ -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

0 comments on commit 0fd0934

Please sign in to comment.