aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-14 07:18:06 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-15 10:14:53 +0800
commitd6a6adf7082909d555914d85cac0a47d218d7b64 (patch)
tree9bfaa03c19a9987d3a019482ba699035f2cce001
parented65724e57d2af13cedc380ecfe4a495dae3afb7 (diff)
downloadrneovim-d6a6adf7082909d555914d85cac0a47d218d7b64.tar.gz
rneovim-d6a6adf7082909d555914d85cac0a47d218d7b64.tar.bz2
rneovim-d6a6adf7082909d555914d85cac0a47d218d7b64.zip
vim-patch:8.2.1658: expand('<stack>') has trailing ".."
Problem: Expand('<stack>') has trailing "..". Solution: Remove the "..". (closes vim/vim#6927) https://github.com/vim/vim/commit/a810db3f17d477e057059c72062c08fd97bcea43
-rw-r--r--src/nvim/runtime.c16
-rw-r--r--src/nvim/testdir/test_expand_func.vim2
2 files changed, 8 insertions, 10 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index fba3dce92d..044294f3b0 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -135,21 +135,19 @@ char *estack_sfile(estack_arg_T which)
}
len += strlen(type_name);
ga_grow(&ga, (int)len);
- linenr_T lnum = 0;
- if (idx == exestack.ga_len - 1) {
- lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;
- } else {
- lnum = entry->es_lnum;
- }
+ linenr_T lnum = idx == exestack.ga_len - 1
+ ? which == ESTACK_STACK ? SOURCING_LNUM : 0
+ : entry->es_lnum;
+ char *dots = idx == exestack.ga_len - 1 ? "" : "..";
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 ? "" : "..");
+ type_name, entry->es_name, dots);
} else {
- vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%" PRIdLINENR "]..",
- type_name, entry->es_name, lnum);
+ vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%" PRIdLINENR "]%s",
+ type_name, entry->es_name, lnum, dots);
}
ga.ga_len += (int)strlen((char *)ga.ga_data + ga.ga_len);
}
diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim
index 3094aad3a4..fc0f7619c4 100644
--- a/src/nvim/testdir/test_expand_func.vim
+++ b/src/nvim/testdir/test_expand_func.vim
@@ -58,7 +58,7 @@ func Test_expand_sfile_and_stack()
END
call writefile(lines, 'Xstack')
source Xstack
- call assert_match('\<Xstack\[2\]', g:stack_value)
+ call assert_match('\<Xstack\[2\]$', g:stack_value)
call delete('Xstack')
endfunc