From 43104f3b08092f0b679c0651260aa3bfa5d9bb6f Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 29 Feb 2024 14:36:49 +0800 Subject: [PATCH 1/2] Fix E1312 when quitting a window The idea is taken from README.md of MattLombana/dotfiles Fixes https://github.com/preservim/tagbar/issues/851 --- autoload/tagbar.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 93cad314..d8de7718 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3541,7 +3541,7 @@ function! s:HandleOnlyWindow() abort try try - quit + call timer_start(0, {-> execute('q', 'silent!') }) catch /.*/ " This can be E173 and maybe others call s:OpenWindow('') echoerr v:exception From 89d99497b26af8ca4ca5163b8a53dafafab38556 Mon Sep 17 00:00:00 2001 From: raven42 Date: Thu, 29 Feb 2024 16:39:59 -0600 Subject: [PATCH 2/2] 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