# HG changeset patch # User Bram Moolenaar # Date 1599840003 -7200 # Node ID 195a617b405ae5b6ff0d8133eccf8b8fa569813b # Parent 50b1e250f302aa891f1ebf980e007b16b780f456 patch 8.2.1658: expand('') has trailing ".." Commit: https://github.com/vim/vim/commit/a810db3f17d477e057059c72062c08fd97bcea43 Author: Bram Moolenaar Date: Fri Sep 11 17:59:23 2020 +0200 patch 8.2.1658: expand('') has trailing ".." Problem: Expand('') has trailing "..". Solution: Remove the "..". (closes https://github.com/vim/vim/issues/6927) diff --git a/src/scriptfile.c b/src/scriptfile.c --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -144,7 +144,8 @@ estack_sfile(estack_arg_T which UNUSED) entry = ((estack_T *)exestack.ga_data) + idx; if (entry->es_name != NULL) { - long lnum = 0; + long lnum = 0; + char *dots; len = STRLEN(entry->es_name) + 15; type_name = ""; @@ -165,16 +166,16 @@ estack_sfile(estack_arg_T which UNUSED) lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0; else lnum = entry->es_lnum; + 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[%ld]..", - type_name, entry->es_name, lnum); + vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%ld]%s", + type_name, entry->es_name, lnum, dots); ga.ga_len += (int)STRLEN((char *)ga.ga_data + ga.ga_len); } } diff --git a/src/testdir/test_expand_func.vim b/src/testdir/test_expand_func.vim --- a/src/testdir/test_expand_func.vim +++ b/src/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('\