mirror of
https://github.com/neovim/neovim.git
synced 2026-01-04 10:26:42 +10:00
Merge pull request #36989 from zeertzjq/vim-9.0.1758
vim-patch:9.{0.1758,1.1983,1.1987}
This commit is contained in:
@@ -195,39 +195,44 @@ char *estack_sfile(estack_arg_T which)
|
||||
for (int idx = 0; idx < exestack.ga_len; idx++) {
|
||||
entry = ((estack_T *)exestack.ga_data) + idx;
|
||||
if (entry->es_name != NULL) {
|
||||
size_t len = strlen(entry->es_name) + 15;
|
||||
char *type_name = "";
|
||||
String type_name = STATIC_CSTR_AS_STRING("");
|
||||
String es_name = cstr_as_string(entry->es_name);
|
||||
if (entry->es_type != last_type) {
|
||||
switch (entry->es_type) {
|
||||
case ETYPE_SCRIPT:
|
||||
type_name = "script "; break;
|
||||
type_name = STATIC_CSTR_AS_STRING("script "); break;
|
||||
case ETYPE_UFUNC:
|
||||
type_name = "function "; break;
|
||||
type_name = STATIC_CSTR_AS_STRING("function "); break;
|
||||
default:
|
||||
type_name = ""; break;
|
||||
break;
|
||||
}
|
||||
last_type = entry->es_type;
|
||||
}
|
||||
len += strlen(type_name);
|
||||
ga_grow(&ga, (int)len);
|
||||
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, dots);
|
||||
} else {
|
||||
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%" PRIdLINENR "]%s",
|
||||
type_name, entry->es_name, lnum, dots);
|
||||
|
||||
size_t len = es_name.size + type_name.size + 26;
|
||||
ga_grow(&ga, (int)len);
|
||||
ga_concat_len(&ga, type_name.data, type_name.size);
|
||||
ga_concat_len(&ga, es_name.data, es_name.size);
|
||||
// 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.
|
||||
if (lnum != 0) {
|
||||
ga.ga_len += (int)vim_snprintf_safelen((char *)ga.ga_data + ga.ga_len,
|
||||
len - (size_t)ga.ga_len,
|
||||
"[%" PRIdLINENR "]", lnum);
|
||||
}
|
||||
if (idx != exestack.ga_len - 1) {
|
||||
ga_concat_len(&ga, S_LEN(".."));
|
||||
}
|
||||
ga.ga_len += (int)strlen((char *)ga.ga_data + ga.ga_len);
|
||||
}
|
||||
}
|
||||
|
||||
// Only NUL-terminate when not returning NULL.
|
||||
if (ga.ga_data != NULL) {
|
||||
ga_append(&ga, NUL);
|
||||
}
|
||||
return (char *)ga.ga_data;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,6 +386,19 @@ func Test_assert_fails_in_timer()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" Check that a typed assert_equal() doesn't prepend an unnecessary ':'.
|
||||
func Test_assert_equal_typed()
|
||||
let after =<< trim END
|
||||
call feedkeys(":call assert_equal(0, 1)\<CR>", 't')
|
||||
call feedkeys(":call writefile(v:errors, 'Xerrors')\<CR>", 't')
|
||||
call feedkeys(":qa!\<CR>", 't')
|
||||
END
|
||||
call assert_equal(1, RunVim([], after, ''))
|
||||
call assert_equal(['Expected 0 but got 1'], readfile('Xerrors'))
|
||||
|
||||
call delete('Xerrors')
|
||||
endfunc
|
||||
|
||||
func Test_assert_beeps()
|
||||
new
|
||||
call assert_equal(0, assert_beeps('normal h'))
|
||||
|
||||
Reference in New Issue
Block a user