1
0
mirror of https://github.com/gryf/tagbar.git synced 2025-12-18 12:00:23 +01:00

Make TagbarOpen command more flexible

This commit is contained in:
Jan Larres
2011-11-23 19:56:31 +13:00
parent c07e878249
commit e9aa349d10
3 changed files with 40 additions and 15 deletions

View File

@@ -1377,10 +1377,21 @@ function! s:ToggleWindow()
endfunction
" s:OpenWindow() {{{2
function! s:OpenWindow(autoclose)
" If the tagbar window is already open don't do anything
function! s:OpenWindow(flags)
let autofocus = a:flags =~# 'f'
let jump = a:flags =~# 'j'
let autoclose = a:flags =~# 'c'
" If the tagbar window is already open check jump flag
" Also set the autoclose flag if requested
let tagbarwinnr = bufwinnr('__Tagbar__')
if tagbarwinnr != -1
if winnr() != tagbarwinnr && jump
execute tagbarwinnr . 'wincmd w'
if autoclose
let w:autoclose = autoclose
endif
endif
return
endif
@@ -1408,13 +1419,13 @@ function! s:OpenWindow(autoclose)
let &eventignore = eventignore_save
call s:InitWindow(a:autoclose)
call s:InitWindow(autoclose)
wincmd p
" Jump back to the tagbar window if autoclose or autofocus is set. Can't
" just stay in it since it wouldn't trigger the update event
if g:tagbar_autoclose || a:autoclose || g:tagbar_autofocus
if g:tagbar_autoclose || autofocus || g:tagbar_autofocus
let tagbarwinnr = bufwinnr('__Tagbar__')
execute tagbarwinnr . 'wincmd w'
endif
@@ -2865,7 +2876,8 @@ function! tagbar#ToggleWindow()
endfunction
function! tagbar#OpenWindow(...)
call s:OpenWindow(a:1)
let flags = a:0 > 0 ? a:1 : ''
call s:OpenWindow(flags)
endfunction
function! tagbar#CloseWindow()