1
0
mirror of https://github.com/gryf/tagbar.git synced 2025-12-17 11:30:28 +01:00

Fixes #650 Correct window positioning defaults (#652)

* 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:
raven42
2020-09-01 08:59:16 -05:00
committed by GitHub
parent e5c864738d
commit e1c2c98922
3 changed files with 45 additions and 42 deletions

View File

@@ -50,27 +50,37 @@ endfunction
function! s:setup_options() abort
if exists('g:tagbar_position')
if g:tagbar_position !~# '\v(top|bottom)'
let previewwin_pos = 'topleft'
else
" Map older deprecated values to correct values
if g:tagbar_position ==# 'top'
let g:tagbar_position = 'leftabove'
elseif g:tagbar_position ==# 'bottom'
let g:tagbar_position = 'rightbelow'
elseif g:tagbar_position ==# 'left'
let g:tagbar_position = 'topleft vertical'
elseif g:tagbar_position ==# 'right'
let g:tagbar_position = 'botright vertical'
endif
if g:tagbar_position !~# 'vertical'
let previewwin_pos = 'rightbelow vertical'
else
let previewwin_pos = 'topleft'
endif
let default_pos = g:tagbar_position
else
if exists('g:tagbar_vertical') && g:tagbar_vertical > 0
let previewwin_pos = 'rightbelow vertical'
if exists('g:tagbar_left') && g:tagbar_left
let default_pos = 'top'
let default_pos = 'leftabove'
else
let default_pos = 'bottom'
let default_pos = 'rightbelow'
endif
let g:tagbar_height = g:tagbar_vertical
elseif exists('g:tagbar_left') && g:tagbar_left
let previewwin_pos = 'topleft'
let default_pos = 'left'
let default_pos = 'topleft vertical'
else
let previewwin_pos = 'topleft'
let default_pos = 'right'
let default_pos = 'botright vertical'
endif
endif
let options = [
@@ -86,6 +96,7 @@ function! s:setup_options() abort
\ ['height', 10],
\ ['indent', 2],
\ ['left', 0],
\ ['position', default_pos],
\ ['previewwin_pos', previewwin_pos],
\ ['show_balloon', 1],
\ ['show_visibility', 1],
@@ -94,7 +105,6 @@ function! s:setup_options() abort
\ ['sort', 1],
\ ['systemenc', &encoding],
\ ['vertical', 0],
\ ['position', default_pos],
\ ['width', 40],
\ ['zoomwidth', 1],
\ ['silent', 0],