Mercurial > vim
diff src/vim9script.c @ 28164:b0b712d48225 v8.2.4607
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Commit: https://github.com/vim/vim/commit/35dc17634dd6da5b90bd1b0160c4ed9e394f4b87
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Mar 22 12:13:54 2022 +0000
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Problem: Sourcing buffer lines may lead to errors for conflicts.
Solution: Add the ++clear argument. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9991)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Mar 2022 13:15:08 +0100 |
parents | f34afadbef47 |
children | 66b245d84f37 |
line wrap: on
line diff
--- a/src/vim9script.c +++ b/src/vim9script.c @@ -59,6 +59,24 @@ current_script_is_vim9(void) } #endif +#ifdef FEAT_EVAL +/* + * Clear Vim9 script-local variables and functions. + */ + void +clear_vim9_scriptlocal_vars(int sid) +{ + hashtab_T *ht = &SCRIPT_VARS(sid); + + hashtab_free_contents(ht); + hash_init(ht); + delete_script_functions(sid); + + // old imports and script variables are no longer valid + free_imports_and_script_vars(sid); +} +#endif + /* * ":vim9script". */ @@ -103,18 +121,9 @@ ex_vim9script(exarg_T *eap UNUSED) } if (si->sn_state == SN_STATE_RELOAD && !found_noclear) - { - hashtab_T *ht = &SCRIPT_VARS(sid); - // Reloading a script without the "noclear" argument: clear // script-local variables and functions. - hashtab_free_contents(ht); - hash_init(ht); - delete_script_functions(sid); - - // old imports and script variables are no longer valid - free_imports_and_script_vars(sid); - } + clear_vim9_scriptlocal_vars(sid); si->sn_state = SN_STATE_HAD_COMMAND; // Store the prefix with the script, it is used to find exported functions.