From 4772da814a798cd88aeb8f5810a464e2f3cbacc9 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Mon, 14 Feb 2011 23:32:57 +1300 Subject: [PATCH] Provide command for autoclosing window regardless of global setting --- plugin/tagbar.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 2084a78..9cd594e 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -763,11 +763,11 @@ function! s:ToggleWindow() return endif - call s:OpenWindow() + call s:OpenWindow(0) endfunction " s:OpenWindow() {{{1 -function! s:OpenWindow() +function! s:OpenWindow(autoclose) if !s:type_init_done call s:InitTypes() endif @@ -820,6 +820,8 @@ function! s:OpenWindow() let s:is_maximized = 0 let s:short_help = 1 + let w:autoclose = a:autoclose + syntax match Comment '^" .*' " Comments syntax match Identifier '^ [^: ]\+[^:]\+$' " Non-scoped kinds syntax match Title '[^(* ]\+\ze\*\? :' " Scope names @@ -877,7 +879,7 @@ function! s:OpenWindow() " Jump back to the tagbar window if autoclose is set. Can't just stay in " it since it wouldn't trigger the update event - if g:tagbar_autoclose + if g:tagbar_autoclose || a:autoclose let tagbarwinnr = bufwinnr('__Tagbar__') execute tagbarwinnr . 'wincmd w' endif @@ -1625,6 +1627,8 @@ endfunction function! s:JumpToTag() let taginfo = s:GetTagInfo(line('.')) + let autoclose = w:autoclose + if empty(taginfo) return endif @@ -1646,7 +1650,7 @@ function! s:JumpToTag() .foldopen! endif - if g:tagbar_autoclose + if g:tagbar_autoclose || autoclose call s:CloseWindow() else call s:HighlightTag(s:current_file) @@ -1796,9 +1800,10 @@ function! TagbarGenerateStatusline() endfunction " Commands {{{1 -command! -nargs=0 TagbarToggle call s:ToggleWindow() -command! -nargs=0 TagbarOpen call s:OpenWindow() -command! -nargs=0 TagbarClose call s:CloseWindow() +command! -nargs=0 TagbarToggle call s:ToggleWindow() +command! -nargs=0 TagbarOpen call s:OpenWindow(0) +command! -nargs=0 TagbarOpenAutoClose call s:OpenWindow(1) +command! -nargs=0 TagbarClose call s:CloseWindow() " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1