Mercurial > vim
diff src/scriptfile.c @ 22208:a607f02fd17a v8.2.1653
patch 8.2.1653: expand('<stack>') does not include the final line number
Commit: https://github.com/vim/vim/commit/4f25b1aba050b85fa97ca2316aa04dd4b0b22530
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 10 19:25:05 2020 +0200
patch 8.2.1653: expand('<stack>') does not include the final line number
Problem: Expand('<stack>') does not include the final line number.
Solution: Add the line nuber. (closes https://github.com/vim/vim/issues/6927)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 10 Sep 2020 19:30:05 +0200 |
parents | a98211c3e14e |
children | 195a617b405a |
line wrap: on
line diff
--- 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); } }