From d6a6adf7082909d555914d85cac0a47d218d7b64 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Aug 2022 07:18:06 +0800 Subject: vim-patch:8.2.1658: expand('') has trailing ".." Problem: Expand('') has trailing "..". Solution: Remove the "..". (closes vim/vim#6927) https://github.com/vim/vim/commit/a810db3f17d477e057059c72062c08fd97bcea43 --- src/nvim/runtime.c | 16 +++++++--------- src/nvim/testdir/test_expand_func.vim | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src') 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 : do not add the line number, // it is used in . 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('\