From ba0123cc91c75b9bed2ee303e9c0e70460765eff Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 2 Feb 2012 21:07:13 +1300 Subject: [PATCH] Fix bug when closing window before a valid files was seen --- autoload/tagbar.vim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index bdc7fc6..a30ce8b 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1540,17 +1540,23 @@ function! s:CloseWindow() if winnr() == tagbarwinnr if winbufnr(2) != -1 - let filebufnr = bufnr(s:known_files.getCurrent().fpath) - " Other windows are open, only close the tagbar one + + let curfile = s:known_files.getCurrent() + call s:winexec('close') " Try to jump to the correct window after closing call s:winexec('wincmd p') - if bufnr('%') != filebufnr - let filewinnr = bufwinnr(filebufnr) - if filewinnr != -1 - call s:winexec(filewinnr . 'wincmd w') + + if !empty(curfile) + let filebufnr = bufnr(curfile.fpath) + + if bufnr('%') != filebufnr + let filewinnr = bufwinnr(filebufnr) + if filewinnr != -1 + call s:winexec(filewinnr . 'wincmd w') + endif endif endif endif