@@ -1135,8 +1135,8 @@ do_source(
11351135 char_u * fname_exp ;
11361136 char_u * firstline = NULL ;
11371137 int retval = FAIL ;
1138- #ifdef FEAT_EVAL
11391138 sctx_T save_current_sctx ;
1139+ #ifdef FEAT_EVAL
11401140 static scid_T last_current_SID = 0 ;
11411141 static int last_current_SID_seq = 0 ;
11421142 funccal_entry_T funccalp_entry ;
@@ -1300,6 +1300,9 @@ do_source(
13001300 time_push (& tv_rel , & tv_start );
13011301#endif
13021302
1303+ save_current_sctx = current_sctx ;
1304+ current_sctx .sc_version = 1 ; // default script version
1305+
13031306#ifdef FEAT_EVAL
13041307# ifdef FEAT_PROFILE
13051308 if (do_profiling == PROF_YES )
@@ -1310,9 +1313,7 @@ do_source(
13101313 // Also starts profiling timer for nested script.
13111314 save_funccal (& funccalp_entry );
13121315
1313- save_current_sctx = current_sctx ;
13141316 current_sctx .sc_lnum = 0 ;
1315- current_sctx .sc_version = 1 ; // default script version
13161317
13171318 // Check if this script was sourced before to finds its SID.
13181319 // Always use a new sequence number.
@@ -1326,7 +1327,6 @@ do_source(
13261327
13271328 // loading the same script again
13281329 si -> sn_state = SN_STATE_RELOAD ;
1329- si -> sn_version = 1 ;
13301330 current_sctx .sc_sid = sid ;
13311331
13321332 // Script-local variables remain but "const" can be set again.
@@ -1484,13 +1484,14 @@ do_source(
14841484 CLEAR_POINTER (si -> sn_save_cpo );
14851485 }
14861486
1487- current_sctx = save_current_sctx ;
14881487 restore_funccal ();
14891488# ifdef FEAT_PROFILE
14901489 if (do_profiling == PROF_YES )
14911490 prof_child_exit (& wait_start ); // leaving a child now
14921491# endif
14931492#endif
1493+ current_sctx = save_current_sctx ;
1494+
14941495 fclose (cookie .fp );
14951496 vim_free (cookie .nextline );
14961497 vim_free (firstline );
@@ -1903,7 +1904,6 @@ ex_scriptencoding(exarg_T *eap)
19031904 void
19041905ex_scriptversion (exarg_T * eap UNUSED )
19051906{
1906- #ifdef FEAT_EVAL
19071907 int nr ;
19081908
19091909 if (!getline_equal (eap -> getline , eap -> cookie , getsourceline ))
@@ -1925,9 +1925,10 @@ ex_scriptversion(exarg_T *eap UNUSED)
19251925 else
19261926 {
19271927 current_sctx .sc_version = nr ;
1928+ #ifdef FEAT_EVAL
19281929 SCRIPT_ITEM (current_sctx .sc_sid )-> sn_version = nr ;
1929- }
19301930#endif
1931+ }
19311932}
19321933
19331934#if defined(FEAT_EVAL ) || defined(PROTO )
0 commit comments