diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 93cad314..ed35c3fe 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3522,13 +3522,17 @@ function! s:HandleOnlyWindow() abort let file_open = s:HasOpenFileWindows() if vim_quitting && file_open == 2 && !g:tagbar_autoclose_netrw - call tagbar#debug#log('Closing Tagbar due to QuitPre - netrw only remaining window') - call s:CloseWindow() + call tagbar#debug#log('Closing Tagbar due to QuitPre - leave netrw') + if has('patch-9.0.907') + call timer_start(10, {-> s:CloseWindow() }) + else + call s:CloseWindow() + endif return endif if vim_quitting && file_open != 1 - call tagbar#debug#log('Closing Tagbar window due to QuitPre event') + call tagbar#debug#log('Closing Tagbar and netrw due to QuitPre event') if winnr('$') >= 1 call s:goto_win(tagbarwinnr, 1) endif @@ -3536,12 +3540,19 @@ function! s:HandleOnlyWindow() abort " Before quitting Vim, delete the tagbar buffer so that the '0 mark is " correctly set to the previous buffer. if tabpagenr('$') == 1 - noautocmd keepalt bdelete + if has('patch-9.0.907') + call timer_start(20, {-> execute('noautocmd keepalt bdelete ' . tagbarwinnr)}) + else + noautocmd keepalt bdelete + endif endif - try try - quit + if has('patch-9.0.907') + call timer_start(50, {-> execute('q', 'silent!') }) + else + quit + endif catch /.*/ " This can be E173 and maybe others call s:OpenWindow('') echoerr v:exception