aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/runtime.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-14 07:07:32 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-15 10:14:53 +0800
commited65724e57d2af13cedc380ecfe4a495dae3afb7 (patch)
tree377f8659f94e379c12e3db944680375aeed2ef3c /src/nvim/runtime.c
parent98ab0bb5f7d2138be0b6019769e237e42aafad1a (diff)
downloadrneovim-ed65724e57d2af13cedc380ecfe4a495dae3afb7.tar.gz
rneovim-ed65724e57d2af13cedc380ecfe4a495dae3afb7.tar.bz2
rneovim-ed65724e57d2af13cedc380ecfe4a495dae3afb7.zip
vim-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 vim/vim#6927) https://github.com/vim/vim/commit/4f25b1aba050b85fa97ca2316aa04dd4b0b22530
Diffstat (limited to 'src/nvim/runtime.c')
-rw-r--r--src/nvim/runtime.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 1cafd22b0a..fba3dce92d 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -100,11 +100,11 @@ void estack_pop(void)
}
/// Get the current value for <sfile> in allocated memory.
-/// @param is_sfile true for <sfile> itself.
-char *estack_sfile(bool is_sfile)
+/// @param which ESTACK_SFILE for <sfile> and ESTACK_STACK for <stack>.
+char *estack_sfile(estack_arg_T which)
{
estack_T *entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
- if (is_sfile && entry->es_type != ETYPE_UFUNC) {
+ if (which == ESTACK_SFILE && entry->es_type != ETYPE_UFUNC) {
if (entry->es_name == NULL) {
return NULL;
}
@@ -135,14 +135,21 @@ char *estack_sfile(bool is_sfile)
}
len += strlen(type_name);
ga_grow(&ga, (int)len);
- 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.
+ linenr_T lnum = 0;
+ 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[%" PRIdLINENR "]..",
- 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);
}