@@ -791,6 +791,7 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
791791 {
792792 int vim9script = in_vim9script ();
793793 char_u * after_script = NULL ;
794+ long sid = 0 ;
794795
795796 if (vim9script )
796797 {
@@ -800,27 +801,27 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
800801 return func ;
801802 }
802803
803- if (!vim9script
804- && name [0 ] == K_SPECIAL
804+ if (name [0 ] == K_SPECIAL
805805 && name [1 ] == KS_EXTRA
806806 && name [2 ] == KE_SNR )
807807 {
808- long sid ;
809-
810808 // Caller changes s: to <SNR>99_name.
811809
812810 after_script = name + 3 ;
813811 sid = getdigits (& after_script );
814- if (sid == current_sctx . sc_sid && * after_script == '_' )
812+ if (* after_script == '_' )
815813 ++ after_script ;
816814 else
817815 after_script = NULL ;
818816 }
819817 if (vim9script || after_script != NULL )
820818 {
821819 // Find imported function before global one.
822- imported = find_imported (
823- after_script == NULL ? name : after_script , 0 , cctx );
820+ if (after_script != NULL && sid != current_sctx .sc_sid )
821+ imported = find_imported_in_script (after_script , 0 , sid );
822+ else
823+ imported = find_imported (after_script == NULL
824+ ? name : after_script , 0 , cctx );
824825 if (imported != NULL && imported -> imp_funcname != NULL )
825826 {
826827 hi = hash_find (& func_hashtab , imported -> imp_funcname );
0 commit comments