From 52fe2b7c3a6c74f1fc8cb311e0bcc6fe8c09fddb Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Fri, 20 Jan 2012 15:56:50 +1300 Subject: [PATCH] Try to jump to the correct window after closing, closes #56 --- autoload/tagbar.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 4877d84..969e6c8 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1527,9 +1527,25 @@ function! s:CloseWindow() if winnr() == tagbarwinnr if winbufnr(2) != -1 + let filebufnr = bufnr(s:known_files.getCurrent().fpath) + + " Ignore BufEnter to prevent MiniBufExplorer from interfering + let eventignore_save = &eventignore + set eventignore=BufEnter + " Other windows are open, only close the tagbar one close + + " Try to jump to the correct window after closing wincmd p + if bufnr('%') != filebufnr + let filewinnr = bufwinnr(filebufnr) + if filewinnr != -1 + execute filewinnr . 'wincmd w' + endif + endif + + let &eventignore = eventignore_save endif else " Go to the tagbar window, close it and then come back to the