summaryrefslogtreecommitdiff
path: root/src/userfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-09-10 21:05:02 +0200
committerBram Moolenaar <Bram@vim.org>2018-09-10 21:05:02 +0200
commitf29c1c6aa3f365c025890fab5fb9efbe88eb1761 (patch)
tree3cd43ee75a7e0fbdce4902426512ae804b1c7ff0 /src/userfunc.c
parent6b0b83f768cf536b34ce4d3f2de6bf62324229aa (diff)
downloadvim-git-f29c1c6aa3f365c025890fab5fb9efbe88eb1761.tar.gz
patch 8.1.0362: cannot get the script line number when executing a functionv8.1.0362
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".
Diffstat (limited to 'src/userfunc.c')
-rw-r--r--src/userfunc.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index a8ea303a9..78a2ecc14 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -302,7 +302,8 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate)
fp->uf_varargs = TRUE;
fp->uf_flags = flags;
fp->uf_calls = 0;
- fp->uf_script_ID = current_SID;
+ fp->uf_script_ctx = current_sctx;
+ fp->uf_script_ctx.sc_lnum += sourcing_lnum - newlines.ga_len;
pt->pt_func = fp;
pt->pt_refcount = 1;
@@ -505,11 +506,11 @@ fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
i = 3;
if (eval_fname_sid(name)) /* "<SID>" or "s:" */
{
- if (current_SID <= 0)
+ if (current_sctx.sc_sid <= 0)
*error = ERROR_SCRIPT;
else
{
- sprintf((char *)fname_buf + 3, "%ld_", (long)current_SID);
+ sprintf((char *)fname_buf + 3, "%ld_", (long)current_sctx.sc_sid);
i = (int)STRLEN(fname_buf);
}
}
@@ -690,7 +691,7 @@ call_user_func(
{
char_u *save_sourcing_name;
linenr_T save_sourcing_lnum;
- scid_T save_current_SID;
+ sctx_T save_current_sctx;
int using_sandbox = FALSE;
funccall_T *fc;
int save_did_emsg;
@@ -944,8 +945,8 @@ call_user_func(
}
#endif
- save_current_SID = current_SID;
- current_SID = fp->uf_script_ID;
+ save_current_sctx = current_sctx;
+ current_sctx = fp->uf_script_ctx;
save_did_emsg = did_emsg;
did_emsg = FALSE;
@@ -1026,7 +1027,7 @@ call_user_func(
vim_free(sourcing_name);
sourcing_name = save_sourcing_name;
sourcing_lnum = save_sourcing_lnum;
- current_SID = save_current_SID;
+ current_sctx = save_current_sctx;
#ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
script_prof_restore(&wait_start);
@@ -1574,7 +1575,7 @@ list_func_head(ufunc_T *fp, int indent)
MSG_PUTS(" closure");
msg_clr_eos();
if (p_verbose > 0)
- last_set_msg(fp->uf_script_ID);
+ last_set_msg(fp->uf_script_ctx);
}
/*
@@ -1757,12 +1758,12 @@ trans_function_name(
|| eval_fname_sid(*pp))
{
/* It's "s:" or "<SID>" */
- if (current_SID <= 0)
+ if (current_sctx.sc_sid <= 0)
{
EMSG(_(e_usingsid));
goto theend;
}
- sprintf((char *)sid_buf, "%ld_", (long)current_SID);
+ sprintf((char *)sid_buf, "%ld_", (long)current_sctx.sc_sid);
lead += (int)STRLEN(sid_buf);
}
}
@@ -2454,7 +2455,8 @@ ex_function(exarg_T *eap)
flags |= FC_SANDBOX;
fp->uf_flags = flags;
fp->uf_calls = 0;
- fp->uf_script_ID = current_SID;
+ fp->uf_script_ctx = current_sctx;
+ fp->uf_script_ctx.sc_lnum += sourcing_lnum - newlines.ga_len - 1;
goto ret_free;
erret: