From ec761c2adf4c6273c8490f0733ca240e40942342 Mon Sep 17 00:00:00 2001 From: Indelog Date: Fri, 12 Nov 2021 09:37:24 +0100 Subject: [PATCH] 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 58410396797054c4bceacaf7142aef7aab545496 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 --- autoload/airline/extensions.vim | 4 +--- autoload/airline/extensions/taglist.vim | 11 +++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 7489c761..b0355b09 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -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 diff --git a/autoload/airline/extensions/taglist.vim b/autoload/airline/extensions/taglist.vim index 430662a9..93c7bb82 100644 --- a/autoload/airline/extensions/taglist.vim +++ b/autoload/airline/extensions/taglist.vim @@ -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)