summaryrefslogtreecommitdiff
path: root/src/scriptfile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-10 19:25:05 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-10 19:25:05 +0200
commit4f25b1aba050b85fa97ca2316aa04dd4b0b22530 (patch)
tree9f051b3953c6eb88e6d5fc1cc5728d348fe626b3 /src/scriptfile.c
parenta953b5cf4f291875b805262eebd361e502de8c92 (diff)
downloadvim-git-4f25b1aba050b85fa97ca2316aa04dd4b0b22530.tar.gz
patch 8.2.1653: expand('<stack>') does not include the final line numberv8.2.1653
Problem: Expand('<stack>') does not include the final line number. Solution: Add the line nuber. (closes #6927)
Diffstat (limited to 'src/scriptfile.c')
-rw-r--r--src/scriptfile.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index e07523695..75182ca51 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -111,10 +111,10 @@ estack_pop(void)
/*
* Get the current value for <sfile> in allocated memory.
- * "is_sfile" is TRUE for <sfile> itself.
+ * "which" is ESTACK_SFILE for <sfile> and ESTACK_STACK for <stack>.
*/
char_u *
-estack_sfile(int is_sfile UNUSED)
+estack_sfile(estack_arg_T which UNUSED)
{
estack_T *entry;
#ifdef FEAT_EVAL
@@ -127,7 +127,7 @@ estack_sfile(int is_sfile UNUSED)
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
#ifdef FEAT_EVAL
- if (is_sfile && entry->es_type != ETYPE_UFUNC)
+ if (which == ESTACK_SFILE && entry->es_type != ETYPE_UFUNC)
#endif
{
if (entry->es_name == NULL)
@@ -144,6 +144,8 @@ estack_sfile(int is_sfile UNUSED)
entry = ((estack_T *)exestack.ga_data) + idx;
if (entry->es_name != NULL)
{
+ long lnum = 0;
+
len = STRLEN(entry->es_name) + 15;
type_name = "";
if (entry->es_type != last_type)
@@ -159,15 +161,20 @@ estack_sfile(int is_sfile UNUSED)
len += STRLEN(type_name);
if (ga_grow(&ga, (int)len) == FAIL)
break;
- if (idx == exestack.ga_len - 1 || entry->es_lnum == 0)
- // For the bottom entry: do not add the line number, it is used
- // in <slnum>. Also leave it out when the number is not set.
+ if (idx == exestack.ga_len - 1)
+ lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;
+ else
+ lnum = entry->es_lnum;
+ if (lnum == 0)
+ // For the bottom entry of <sfile>: do not add the line number,
+ // it is used in <slnum>. Also leave it out when the number is
+ // not set.
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s%s",
type_name, entry->es_name,
idx == exestack.ga_len - 1 ? "" : "..");
else
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%ld]..",
- type_name, entry->es_name, entry->es_lnum);
+ type_name, entry->es_name, lnum);
ga.ga_len += (int)STRLEN((char *)ga.ga_data + ga.ga_len);
}
}