From 89d99497b26af8ca4ca5163b8a53dafafab38556 Mon Sep 17 00:00:00 2001 From: raven42 Date: Thu, 29 Feb 2024 16:39:59 -0600 Subject: [PATCH] Update to handle vim-8 and vim-9 and rework a couple other spots --- autoload/tagbar.vim | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index d8de7718..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 - call timer_start(0, {-> execute('q', 'silent!') }) + 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