mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-18 12:00:23 +01:00
Add g:tagbar_jump_offset configuration (#695)
Closes #504 Add a new `g:tagbar_jump_offset` value which will control the tag jump location relative to the center of the screen.
This commit is contained in:
@@ -2279,6 +2279,21 @@ function! s:JumpToTag(stay_in_tagbar) abort
|
||||
" Center the tag in the window and jump to the correct column if
|
||||
" available, otherwise try to find it in the line
|
||||
normal! z.
|
||||
|
||||
" If configured, adjust the jump_offset and center the window on that
|
||||
" line. Then fall-through adjust the cursor() position below that
|
||||
if g:tagbar_jump_offset != 0 && g:tagbar_jump_offset < curline
|
||||
if g:tagbar_jump_offset > winheight(0) / 2
|
||||
let jump_offset = winheight(0) / 2
|
||||
elseif g:tagbar_jump_offset < -winheight(0) / 2
|
||||
let jump_offset = -winheight(0) / 2
|
||||
else
|
||||
let jump_offset = g:tagbar_jump_offset
|
||||
endif
|
||||
execute curline+jump_offset
|
||||
normal! z.
|
||||
endif
|
||||
|
||||
if taginfo.fields.column > 0
|
||||
call cursor(taginfo.fields.line, taginfo.fields.column)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user