taglist: correctly check for right taglist plugin

Avoid the error `Unknown function: taglist#Tlist_Get_Tagname_By_Line`
when using the old tag tlist plugin in a different way.

this means, we have to revert 5841039679
since exists() does not handle autoloaded functions correctly.

We can only check it, after we have used the taglist plugin, so that the
autoloading has happened. That means, move the exists() call after the
`:TListUpdate` call which will correctly autoload taglist and then
exists() can check for the existence of the
`taglist#Tlist_Get_Tagname_By_Line()` function correctly.

closes: #2463
This commit is contained in:
Indelog 2021-11-12 09:37:24 +01:00 committed by Christian Brabandt
parent 5841039679
commit ec761c2adf
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 10 additions and 5 deletions

View File

@ -249,9 +249,7 @@ function! airline#extensions#load()
call airline#extensions#tagbar#init(s:ext)
call add(s:loaded_ext, 'tagbar')
endif
if get(g:, 'airline#extensions#taglist#enabled', 1)
\ && exists(':TlistShowTag')
\ && exists('*taglist#Tlist_Get_Tagname_By_Line')
if get(g:, 'airline#extensions#taglist#enabled', 1) && exists(':TlistShowTag')
call airline#extensions#taglist#init(s:ext)
call add(s:loaded_ext, 'taglist')
endif

View File

@ -4,7 +4,7 @@
scriptencoding utf-8
if !exists(':TlistShowTag') && !exists('*taglist#Tlist_Get_Tagname_By_Line')
if !exists(':TlistShowTag')
finish
endif
@ -21,7 +21,14 @@ function! airline#extensions#taglist#currenttag()
let tlist_updated = v:true
endif
endif
return taglist#Tlist_Get_Tagname_By_Line()
" Is this function is not present it'means you use the old vertsion of
" tag list : https://github.com/vim-scripts/taglist.vim.
" Please use the new version : https://github.com/yegappan/taglist.
if exists('*taglist#Tlist_Get_Tagname_By_Line()')
return taglist#Tlist_Get_Tagname_By_Line()
else
return ''
endif
endfunction
function! airline#extensions#taglist#init(ext)