]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0920: cannot find an import prefixed with "s:" v9.0.0920
authorBram Moolenaar <Bram@vim.org>
Tue, 22 Nov 2022 18:12:44 +0000 (18:12 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 22 Nov 2022 18:12:44 +0000 (18:12 +0000)
Problem:    Cannot find an import prefixed with "s:". (Doug Kearns)
Solution:   Skip over the "s:". (closes #11585)

src/testdir/test_vim9_import.vim
src/version.c
src/vim9compile.c

index dba91c3a3fcc9e0dbfe08b2dae1a5006a5670ccd..97d1cffc1c450b5459908f3e4df32063f3f9a34a 100644 (file)
@@ -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()
index e09e397c2288686b9af7c47cc3ad8c50321dbe6c..3dbf2ef1eb5d1cbf7b5544aea9ebe2caf0900a99 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    920,
 /**/
     919,
 /**/
index fb66a788061f21e787f43ce7622aba2683e695bb..17066b0e9cc7806b00a3da094b1ea51af172d591 100644 (file)
@@ -656,12 +656,14 @@ find_imported_in_script(char_u *name, size_t len, int sid)
     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;