Fixes 845: Call init on update (#897)
Some checks failed
Check / check (exuberant-ctags, nvim) (push) Has been cancelled
Check / check (exuberant-ctags, vim) (push) Has been cancelled
Check / check (universal-ctags, nvim) (push) Has been cancelled
Check / check (universal-ctags, vim) (push) Has been cancelled
Vint / vint (push) Has been cancelled

If tagbar is not yet initialized, then initialize it upon call to `Update() | jump() | jumpToNearbyTag()`. This will ensure that we have loaded the file.
This commit is contained in:
David Hegland 2024-12-27 07:24:17 -06:00 committed by GitHub
parent 5e090da54b
commit 8de7694c0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3834,6 +3834,9 @@ endfunction
" tagbar#Update() {{{2
" Trigger an AutoUpdate() of the currently opened file
function! tagbar#Update() abort
if s:init_done == 0
call s:Init(0)
endif
call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0)
endfunction
@ -4096,6 +4099,9 @@ endfunction
" tagbar#jump() {{{2
function! tagbar#jump() abort
if s:init_done == 0
call tagbar#Update()
endif
if &filetype !=# 'tagbar'
" Not in tagbar window - ignore this function call
return
@ -4110,6 +4116,9 @@ endfun
" [flags] = list of flags (as a string) to control behavior
" 's' - use the g:tagbar_scroll_offset setting when jumping
function! tagbar#jumpToNearbyTag(direction, ...) abort
if s:init_done == 0
call tagbar#Update()
endif
let search_method = a:0 >= 1 ? a:1 : 'nearest-stl'
let flags = a:0 >= 2 ? a:2 : ''