diff src/vim9execute.c @ 24471:baf75c8e1b7b v8.2.2775

patch 8.2.2775: Vim9: wrong line number used for some commands Commit: https://github.com/vim/vim/commit/c70fe460b09f6182a13e4385f3232df4fdcd0741 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 17 17:59:19 2021 +0200 patch 8.2.2775: Vim9: wrong line number used for some commands Problem: Vim9: wrong line number used for some commands. Solution: For :exe, :echo and the like use the line number of the start of the command. When calling a function set the line number in the script context.
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Apr 2021 18:00:04 +0200
parents 53216e87f21c
children 96905804bf5a
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -329,9 +329,9 @@ call_dfunc(
     if (entry != NULL)
     {
 	// Set the script context to the script where the function was defined.
-	// TODO: save more than the SID?
-	entry->es_save_sid = current_sctx.sc_sid;
-	current_sctx.sc_sid = ufunc->uf_script_ctx.sc_sid;
+	// Save the current context so it can be restored on return.
+	entry->es_save_sctx = current_sctx;
+	current_sctx = ufunc->uf_script_ctx;
     }
 
     // Start execution at the first instruction.
@@ -562,7 +562,7 @@ func_return(funclocal_T *funclocal, ectx
     // execution context goes one level up
     entry = estack_pop();
     if (entry != NULL)
-	current_sctx.sc_sid = entry->es_save_sid;
+	current_sctx = entry->es_save_sctx;
 
     if (handle_closure_in_use(ectx, TRUE) == FAIL)
 	return FAIL;