vim-patch:8.2.1658: expand('<stack>') has trailing ".."

Problem:    Expand('<stack>') has trailing "..".
Solution:   Remove the "..". (closes vim/vim#6927)
a810db3f17
This commit is contained in:
zeertzjq 2022-08-14 07:18:06 +08:00
parent ed65724e57
commit d6a6adf708
2 changed files with 8 additions and 10 deletions

View File

@ -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);
}

View File

@ -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