diff src/vim9script.c @ 27074:19fefc42a063 v8.2.4066

patch 8.2.4066: Vim9: imported autoload script loaded again Commit: https://github.com/vim/vim/commit/17d36cbcd36d944c744ef68afa971718959b2111 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 12 11:46:40 2022 +0000 patch 8.2.4066: Vim9: imported autoload script loaded again Problem: Vim9: imported autoload script loaded again. Solution: Do not create a new imported_T every time.
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Jan 2022 13:00:06 +0100
parents 8f6cab688901
children 1e2a6c6c7e42
line wrap: on
line diff
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -250,6 +250,8 @@ ex_incdec(exarg_T *eap)
     void
 ex_export(exarg_T *eap)
 {
+    int	    prev_did_emsg = did_emsg;
+
     if (!in_vim9script())
     {
 	emsg(_(e_export_can_only_be_used_in_vim9script));
@@ -273,12 +275,14 @@ ex_export(exarg_T *eap)
 	    // The command will reset "is_export" when exporting an item.
 	    if (is_export)
 	    {
-		emsg(_(e_export_with_invalid_argument));
+		if (did_emsg == prev_did_emsg)
+		    emsg(_(e_export_with_invalid_argument));
 		is_export = FALSE;
 	    }
 	    break;
 	default:
-	    emsg(_(e_invalid_command_after_export));
+	    if (did_emsg == prev_did_emsg)
+		emsg(_(e_invalid_command_after_export));
 	    break;
     }
 }
@@ -589,14 +593,17 @@ handle_import(
 		&& check_defined(as_name, STRLEN(as_name), cctx, FALSE) == FAIL)
 	    goto erret;
 
-	imported = new_imported(import_gap);
 	if (imported == NULL)
-	    goto erret;
-	imported->imp_name = as_name;
-	as_name = NULL;
-	imported->imp_sid = sid;
-	if (is_autoload)
-	    imported->imp_flags = IMP_FLAGS_AUTOLOAD;
+	{
+	    imported = new_imported(import_gap);
+	    if (imported == NULL)
+		goto erret;
+	    imported->imp_name = as_name;
+	    as_name = NULL;
+	    imported->imp_sid = sid;
+	    if (is_autoload)
+		imported->imp_flags = IMP_FLAGS_AUTOLOAD;
+	}
     }
 
 erret: