vim-patch:9.1.1987: assert_equal() prepends unnecessary ':' when typed

Problem:  assert_equal() prepends unnecessary ':' when typed
          (after 9.0.1758).
Solution: Don't change a NULL stacktrace to an empty string (zeertzjq).

closes: vim/vim#18936

c4b3aefd0d
This commit is contained in:
zeertzjq
2025-12-17 06:46:22 +08:00
parent 6061169183
commit 544bde3acc
2 changed files with 17 additions and 1 deletions

View File

@@ -229,7 +229,10 @@ char *estack_sfile(estack_arg_T which)
}
}
ga_append(&ga, NUL);
// Only NUL-terminate when not returning NULL.
if (ga.ga_data != NULL) {
ga_append(&ga, NUL);
}
return (char *)ga.ga_data;
}

View File

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