diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index d835ee9..d780a37 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1711,7 +1711,8 @@ function! s:OpenWindow(flags) abort " Expand the Vim window to accomodate for the Tagbar window if requested " and save the window positions to be able to restore them later. - if g:tagbar_expand && !s:window_expanded && has('gui_running') + if g:tagbar_expand >= 1 && !s:window_expanded && + \ (has('gui_running') || g:tagbar_expand == 2) let s:window_pos.pre.x = getwinposx() let s:window_pos.pre.y = getwinposy() let &columns += g:tagbar_width + 1 @@ -1869,13 +1870,14 @@ function! s:CloseWindow() abort if index(tablist, tagbarbufnr) == -1 let &columns -= g:tagbar_width + 1 let s:window_expanded = 0 - " Only restore window position if it hasn't been moved manually - " after the expanding - if getwinposx() == s:window_pos.post.x && + " Only restore window position if it is available and if the + " window hasn't been moved manually after the expanding + if getwinposx() != -1 && + \ getwinposx() == s:window_pos.post.x && \ getwinposy() == s:window_pos.post.y execute 'winpos ' . s:window_pos.pre.x . \ ' ' . s:window_pos.pre.y - endif + endif endif endif diff --git a/doc/tagbar.txt b/doc/tagbar.txt index aa4605f..8ed716f 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -491,8 +491,9 @@ Example: g:tagbar_expand~ Default: 0 -If this option is set the Vim window will be expanded by the width of the -Tagbar window if using a GUI version of Vim. +If this option is set to 1 the Vim window will be expanded by the width of the +Tagbar window if using a GUI version of Vim. Setting it to 2 will also try +expanding a terminal, but note that this is not supported by all terminals. Example: >