diff src/eval.c @ 14700:0a3b9ecf7cb8 v8.1.0362

patch 8.1.0362: cannot get the script line number when executing a function commit https://github.com/vim/vim/commit/f29c1c6aa3f365c025890fab5fb9efbe88eb1761 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 10 21:05:02 2018 +0200 patch 8.1.0362: cannot get the script line number when executing a function Problem: Cannot get the script line number when executing a function. Solution: Store the line number besides the script ID. (Ozaki Kiichi, closes #3362) Also display the line number with ":verbose set".
author Christian Brabandt <cb@256bit.org>
date Mon, 10 Sep 2018 21:15:07 +0200
parents e4c553e9132b
children 27b9a84395b5
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1495,8 +1495,8 @@ list_vim_vars(int *first)
     static void
 list_script_vars(int *first)
 {
-    if (current_SID > 0 && current_SID <= ga_scripts.ga_len)
-	list_hashtable_vars(&SCRIPT_VARS(current_SID),
+    if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= ga_scripts.ga_len)
+	list_hashtable_vars(&SCRIPT_VARS(current_sctx.sc_sid),
 						(char_u *)"s:", FALSE, first);
 }
 
@@ -7202,7 +7202,7 @@ find_var_in_ht(
 	/* Must be something like "s:", otherwise "ht" would be NULL. */
 	switch (htname)
 	{
-	    case 's': return &SCRIPT_SV(current_SID)->sv_var;
+	    case 's': return &SCRIPT_SV(current_sctx.sc_sid)->sv_var;
 	    case 'g': return &globvars_var;
 	    case 'v': return &vimvars_var;
 	    case 'b': return &curbuf->b_bufvar;
@@ -7286,8 +7286,8 @@ find_var_ht(char_u *name, char_u **varna
     if (*name == 'l')				/* l: local function variable */
 	return get_funccal_local_ht();
     if (*name == 's'				/* script variable */
-	    && current_SID > 0 && current_SID <= ga_scripts.ga_len)
-	return &SCRIPT_VARS(current_SID);
+	    && current_sctx.sc_sid > 0 && current_sctx.sc_sid <= ga_scripts.ga_len)
+	return &SCRIPT_VARS(current_sctx.sc_sid);
     return NULL;
 }
 
@@ -8729,20 +8729,25 @@ store_session_globals(FILE *fd)
  * Should only be invoked when 'verbose' is non-zero.
  */
     void
-last_set_msg(scid_T scriptID)
+last_set_msg(sctx_T script_ctx)
 {
     char_u *p;
 
-    if (scriptID != 0)
-    {
-	p = home_replace_save(NULL, get_scriptname(scriptID));
+    if (script_ctx.sc_sid != 0)
+    {
+	p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
 	if (p != NULL)
 	{
 	    verbose_enter();
 	    MSG_PUTS(_("\n\tLast set from "));
 	    MSG_PUTS(p);
+	    if (script_ctx.sc_lnum > 0)
+	    {
+		MSG_PUTS(_(" line "));
+		msg_outnum((long)script_ctx.sc_lnum);
+	    }
+	    verbose_leave();
 	    vim_free(p);
-	    verbose_leave();
 	}
     }
 }