Mercurial > vim
changeset 31172:4bde058d0be7 v9.0.0920
patch 9.0.0920: cannot find an import prefixed with "s:"
Commit: https://github.com/vim/vim/commit/b775e724394e05f3648fcb5f977979a592dd3f8c
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 22 18:12:44 2022 +0000
patch 9.0.0920: cannot find an import prefixed with "s:"
Problem: Cannot find an import prefixed with "s:". (Doug Kearns)
Solution: Skip over the "s:". (closes https://github.com/vim/vim/issues/11585)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Nov 2022 19:15:02 +0100 |
parents | ea19046c05f2 |
children | 214f1a17a6c9 |
files | src/testdir/test_vim9_import.vim src/version.c src/vim9compile.c |
diffstat | 3 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -2034,6 +2034,15 @@ def Test_source_vim9_from_legacy() source Xlegacy_script.vim assert_equal('global', g:global) unlet g:global + + legacy_lines =<< trim END + import './Xvim9_script.vim' + let g:global = s:Xvim9_script.GetText() + END + writefile(legacy_lines, 'Xlegacyimport.vim', 'D') + source Xlegacyimport.vim + assert_equal('text', g:global) + unlet g:global enddef def Test_import_vim9_from_legacy()
--- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 920, +/**/ 919, /**/ 918,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -656,12 +656,14 @@ find_imported_in_script(char_u *name, si imported_T * find_imported(char_u *name, size_t len, int load) { - imported_T *ret; - if (!SCRIPT_ID_VALID(current_sctx.sc_sid)) return NULL; - ret = find_imported_in_script(name, len, current_sctx.sc_sid); + // Skip over "s:" before "s:something" to find the import name. + int off = name[0] == 's' && name[1] == ':' ? 2 : 0; + + imported_T *ret = find_imported_in_script(name + off, len - off, + current_sctx.sc_sid); if (ret != NULL && load && (ret->imp_flags & IMP_FLAGS_AUTOLOAD)) { scid_T actual_sid = 0;