mirror of
https://github.com/preservim/tagbar.git
synced 2025-02-13 23:22:44 +08:00
Quit if no more normal window exists
There might be other plugin windows but no normal file window open, we need to make sure tagbar window is closed at this situation.
This commit is contained in:
parent
1181325968
commit
a444c62066
|
@ -3359,7 +3359,7 @@ endfunction
|
|||
" s:QuitIfOnlyWindow() {{{2
|
||||
function! s:QuitIfOnlyWindow() abort
|
||||
" Check if there is more than window
|
||||
if winbufnr(2) == -1
|
||||
if s:NextNormalWindow() == -1
|
||||
" Check if there is more than one tab page
|
||||
if tabpagenr('$') == 1
|
||||
" Before quitting Vim, delete the tagbar buffer so that
|
||||
|
@ -3372,6 +3372,41 @@ function! s:QuitIfOnlyWindow() abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" s:NextNormalWindow() {{{2
|
||||
fun! s:NextNormalWindow()
|
||||
let l:i = 1
|
||||
while(l:i <= winnr('$'))
|
||||
let l:buf = winbufnr(l:i)
|
||||
|
||||
" skip unlisted buffers
|
||||
if buflisted(l:buf) == 0
|
||||
let l:i = l:i + 1
|
||||
continue
|
||||
endif
|
||||
|
||||
" skip un-modifiable buffers
|
||||
if getbufvar(l:buf, '&modifiable') != 1
|
||||
let l:i = l:i + 1
|
||||
continue
|
||||
endif
|
||||
|
||||
" skip temporary buffers with buftype set
|
||||
if empty(getbufvar(l:buf, "&buftype")) != 1
|
||||
let l:i = l:i + 1
|
||||
continue
|
||||
endif
|
||||
|
||||
" skip current normal window
|
||||
if l:i == winnr()
|
||||
let l:i = l:i + 1
|
||||
continue
|
||||
endif
|
||||
|
||||
return l:i
|
||||
endwhile
|
||||
return -1
|
||||
endfun
|
||||
|
||||
" s:winexec() {{{2
|
||||
function! s:winexec(cmd) abort
|
||||
call s:LogDebugMessage("Executing without autocommands: " . a:cmd)
|
||||
|
|
Loading…
Reference in New Issue
Block a user