Skip to content

Workaround issues loading session files

Choose a tag to compare

@MiguelBarro MiguelBarro released this 20 Nov 00:11
· 17 commits to main since this release
f8e4573

ftplugins as ordinary plugins are only loaded once. Though restoring sessions seems to arise issues with the 'tagfunc'.
it is recorded in the session as:

set tagfunc=s:cpptagfunc

but using it resolves the actual scriptname. for example:

:function /cpp
    function <snr>80_cpptagfunc

but after restoring a session a mismatch happens. By using :tag or :tsel it complains that <snr>80_cpptagfunc no longer exists and:

:function /cpp
    function <snr>84_cpptagfunc

that is, the ftpluing was reloaded but 'tagfunc' keeps pointing to the old one.
Fixing this is relatively easy. no longer reference a script function but a global one. in this case I define the function in an autoload/cpptags.vim script. By doing so:

set tagfunc=cpptags#cpptagfunc

and no mismatch is possible.