From: zeertzjq Date: Tue, 16 Dec 2025 19:07:27 +0000 (+0100) Subject: patch 9.1.1987: assert_equal() prepends unnecessary ':' when typed X-Git-Tag: v9.1.1987^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4b3aefd0d5f81693e7098f224d3e4bfe24a7aa7;p=thirdparty%2Fvim.git 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: #18936 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- diff --git a/src/scriptfile.c b/src/scriptfile.c index 13bb8177cb..b98c4e2952 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -226,7 +226,7 @@ estack_sfile(estack_arg_T which UNUSED) ga_concat_len(&ga, type_name.string, type_name.length); // For class methods prepend "." to the function name. if (*class_name.string != NUL) - ga.ga_len += vim_snprintf_safelen( + ga.ga_len += (int)vim_snprintf_safelen( (char *)ga.ga_data + ga.ga_len, len - (size_t)ga.ga_len, "%d_%s.", @@ -236,7 +236,7 @@ estack_sfile(estack_arg_T which UNUSED) // 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. if (lnum != 0) - ga.ga_len += vim_snprintf_safelen( + ga.ga_len += (int)vim_snprintf_safelen( (char *)ga.ga_data + ga.ga_len, len - (size_t)ga.ga_len, "[%ld]", @@ -246,7 +246,9 @@ estack_sfile(estack_arg_T which UNUSED) } } - ga_append(&ga, NUL); + // Only NUL-terminate when not returning NULL. + if (ga.ga_data != NULL) + ga_append(&ga, NUL); return (char_u *)ga.ga_data; #endif } diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim index ad4e751c4b..b3e640c11f 100644 --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -381,6 +381,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)\", 't') + call feedkeys(":call writefile(v:errors, 'Xerrors')\", 't') + call feedkeys(":qa!\", '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')) diff --git a/src/version.c b/src/version.c index 1343253f36..a4d7a1bf74 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1987, /**/ 1986, /**/