From c57dd9f7a4ac42a20f5f1a4967ca17f9d3fff018 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Wed, 13 Nov 2013 16:53:52 +1300 Subject: [PATCH] Make sure QuitIfOnlyWindow also works with prevwin open --- autoload/tagbar.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 684cda0..777ac27 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -962,7 +962,6 @@ function! s:CreateAutocommands() abort augroup TagbarAutoCmds autocmd! - autocmd BufEnter __Tagbar__ nested call s:QuitIfOnlyWindow() autocmd CursorHold __Tagbar__ call s:ShowPrototype(1) autocmd WinEnter __Tagbar__ call s:SetStatusLine('current') autocmd WinLeave __Tagbar__ call s:SetStatusLine('noncurrent') @@ -971,6 +970,7 @@ function! s:CreateAutocommands() abort autocmd CursorMoved __Tagbar__ nested call s:ShowInPreviewWin() endif + autocmd BufEnter * nested call s:QuitIfOnlyWindow() autocmd WinEnter * if bufwinnr('__Tagbar__') == -1 | \ call s:ShrinkIfExpanded() | \ endif @@ -3681,6 +3681,14 @@ endfunction " s:QuitIfOnlyWindow() {{{2 function! s:QuitIfOnlyWindow() abort + let tagbarwinnr = bufwinnr('__Tagbar__') + if tagbarwinnr == -1 + return + endif + + let curwinnr = winnr() + call s:winexec('noautocmd ' . tagbarwinnr . 'wincmd w') + " Check if there is more than one window if s:NextNormalWindow() == -1 " Check if there is more than one tab page @@ -3697,6 +3705,8 @@ function! s:QuitIfOnlyWindow() abort close endif endif + + call s:winexec('noautocmd ' . curwinnr . 'wincmd w') endfunction " s:NextNormalWindow() {{{2