mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 11:30:28 +01:00
* Fix for window positioning With default case having multiple vertically split windows, the tagbar window should open on the far right of the screen. When the feature in pull-request 630 was added, this behavior changed to open the tagbar window relative to the current window. This commit will fix that by allowing direct usage of the vim split options. Validated the following cases for the old default values. These all still behave the same way as prior to pull-request 630 when the tagbar is activated in the `active` window shown in the below examples: ``` " No options +-----------------------------------+ | preview | +--------+--------+--------+--------+ | edit | edit | edit | tagbar | | | active | | | +--------+--------+--------+--------+ " tagbar on left, preview above let g:tagbar_left = 1 +-----------------------------------+ | preview | +--------+--------+--------+--------+ | tagbar | edit | edit | edit | | | | active | | +--------+--------+--------+--------+ " tagbar on bottom, preview to right of tagbar let g:tagbar_vertical = 10 +--------+---------------+--------+ | edit | edit | edit | | | active | | | +-----+---------+ | | | tag | preview | | +--------+-----+---------+--------+ " tagbar on top, preview to the right of tagbar let g:tagbar_left = 1 let g:tagbar_vertical = 10 +--------+-----+---------+--------+ | edit | tag | preview | edit | | +-----+---------+ | | | edit | | | | active | | +--------+---------------+--------+ ``` New values also all validated using the following: ``` " Behaves the same as no options let g:tagbar_position = 'right' " Behaves the same as g:tagbar_left = 1 let g:tagbar_position = 'left' " Behaves the same as g:tagbar_vertical = <#> let g:tagbar_position = 'bottom' " Behaves the same as g:tagbar_left = 1 | g:tagbar_vertical = <#> let g:tagbar_position = 'top' ``` * #650 - Fix typo in doc/tagbar.txt for g:tagbar_height option
This commit is contained in:
@@ -879,24 +879,15 @@ function! s:OpenWindow(flags) abort
|
||||
endif
|
||||
|
||||
let s:window_opening = 1
|
||||
if g:tagbar_position =~# '\v(bottom|right)'
|
||||
let openpos = 'rightbelow '
|
||||
else
|
||||
let openpos = 'leftabove '
|
||||
endif
|
||||
if g:tagbar_position =~# '\v(left|right)'
|
||||
if g:tagbar_position =~# 'vertical'
|
||||
let size = g:tagbar_width
|
||||
let mode = 'vertical '
|
||||
let width = g:tagbar_width
|
||||
else
|
||||
let size = g:tagbar_height
|
||||
let mode = ''
|
||||
if g:tagbar_height > 0
|
||||
let width = g:tagbar_height
|
||||
else
|
||||
let width = g:tagbar_vertical
|
||||
endif
|
||||
endif
|
||||
exe 'silent keepalt ' . openpos . mode . width . 'split ' . s:TagbarBufName()
|
||||
exe 'silent ' . mode . 'resize ' . width
|
||||
exe 'silent keepalt ' . g:tagbar_position . size . 'split ' . s:TagbarBufName()
|
||||
exe 'silent ' . mode . 'resize ' . size
|
||||
unlet s:window_opening
|
||||
|
||||
call s:InitWindow(autoclose)
|
||||
@@ -2294,7 +2285,7 @@ function! s:ShowInPreviewWin() abort
|
||||
" We want the preview window to be relative to the file window in normal
|
||||
" (horizontal) mode, and relative to the Tagbar window in vertical mode,
|
||||
" to make the best use of space.
|
||||
if g:tagbar_position !~# '\v(top|bottom)'
|
||||
if g:tagbar_position =~# 'vertical'
|
||||
call s:GotoFileWindow(taginfo.fileinfo, 1)
|
||||
call s:mark_window()
|
||||
endif
|
||||
@@ -2305,7 +2296,7 @@ function! s:ShowInPreviewWin() abort
|
||||
silent execute
|
||||
\ g:tagbar_previewwin_pos . ' pedit ' .
|
||||
\ fnameescape(taginfo.fileinfo.fpath)
|
||||
if g:tagbar_position =~# '\v(top|bottom)'
|
||||
if g:tagbar_position !~# 'vertical'
|
||||
silent execute 'vertical resize ' . g:tagbar_width
|
||||
endif
|
||||
" Remember that the preview window was opened by Tagbar so we can
|
||||
@@ -2313,7 +2304,7 @@ function! s:ShowInPreviewWin() abort
|
||||
let s:pwin_by_tagbar = 1
|
||||
endif
|
||||
|
||||
if g:tagbar_position =~# '\v(top|bottom)'
|
||||
if g:tagbar_position !~# 'vertical'
|
||||
call s:GotoFileWindow(taginfo.fileinfo, 1)
|
||||
call s:mark_window()
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user