0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2485: when sourcing a script again the script version isn't reset

Problem:    When sourcing a script again the script version isn't reset.
Solution:   Set sn_version to one when sourcing a script again. Clear
            sn_save_cpo properly. (closes #7608)
This commit is contained in:
Bram Moolenaar
2021-02-07 17:17:58 +01:00
parent dee37dc733
commit 0123cc1e14
3 changed files with 20 additions and 2 deletions

View File

@@ -1319,6 +1319,9 @@ do_source(
} }
// imports can be redefined once // imports can be redefined once
mark_imports_for_reload(sid); mark_imports_for_reload(sid);
// reset version, "vim9script" may have been added or removed.
si->sn_version = 1;
} }
else else
{ {
@@ -1457,7 +1460,7 @@ almosttheend:
if (si->sn_save_cpo != NULL) if (si->sn_save_cpo != NULL)
{ {
set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0); set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0);
CLEAR_POINTER(si->sn_save_cpo); VIM_CLEAR(si->sn_save_cpo);
} }
restore_funccal(); restore_funccal();

View File

@@ -2207,7 +2207,7 @@ def Test_while_loop()
assert_equal('1_3_', result) assert_equal('1_3_', result)
var s = '' var s = ''
while s == 'x' #{comment while s == 'x' #{comment}
endwhile endwhile
enddef enddef
@@ -3155,6 +3155,19 @@ def Test_restoring_cpo()
delete('Xsourced') delete('Xsourced')
delete('Xclose') delete('Xclose')
delete('Xdone') delete('Xdone')
writefile(['vim9script'], 'XanotherScript')
set cpo=aABceFsMny>
edit XanotherScript
so %
assert_equal('aABceFsMny>', &cpo)
:1del
w
so %
assert_equal('aABceFsMny>', &cpo)
delete('XanotherScript')
set cpo&vim
enddef enddef

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2485,
/**/ /**/
2484, 2484,
/**/ /**/