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".
diff --git a/src/fileio.c b/src/fileio.c
index d00dc5e..056ac91 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7700,7 +7700,7 @@
char nested; /* If autocommands nest here */
char last; /* last command in list */
#ifdef FEAT_EVAL
- scid_T scriptID; /* script ID where defined */
+ sctx_T script_ctx; /* script context where defined */
#endif
struct AutoCmd *next; /* Next AutoCmd in list */
} AutoCmd;
@@ -7962,7 +7962,7 @@
msg_outtrans(ac->cmd);
#ifdef FEAT_EVAL
if (p_verbose > 0)
- last_set_msg(ac->scriptID);
+ last_set_msg(ac->script_ctx);
#endif
if (got_int)
return;
@@ -8845,7 +8845,8 @@
return FAIL;
ac->cmd = vim_strsave(cmd);
#ifdef FEAT_EVAL
- ac->scriptID = current_SID;
+ ac->script_ctx = current_sctx;
+ ac->script_ctx.sc_lnum += sourcing_lnum;
#endif
if (ac->cmd == NULL)
{
@@ -9412,7 +9413,7 @@
AutoPatCmd patcmd;
AutoPat *ap;
#ifdef FEAT_EVAL
- scid_T save_current_SID;
+ sctx_T save_current_sctx;
void *save_funccalp;
char_u *save_cmdarg;
long save_cmdbang;
@@ -9621,7 +9622,7 @@
sourcing_lnum = 0; /* no line number here */
#ifdef FEAT_EVAL
- save_current_SID = current_SID;
+ save_current_sctx = current_sctx;
# ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
@@ -9725,7 +9726,7 @@
autocmd_bufnr = save_autocmd_bufnr;
autocmd_match = save_autocmd_match;
#ifdef FEAT_EVAL
- current_SID = save_current_SID;
+ current_sctx = save_current_sctx;
restore_funccal(save_funccalp);
# ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
@@ -9949,7 +9950,7 @@
retval = vim_strsave(ac->cmd);
autocmd_nested = ac->nested;
#ifdef FEAT_EVAL
- current_SID = ac->scriptID;
+ current_sctx = ac->script_ctx;
#endif
if (ac->last)
acp->nextcmd = NULL;