From: thinca Date: Sat, 31 Jan 2026 09:52:00 +0000 (+0000) Subject: patch 9.1.2120: blob2str() does not restore trailing newline X-Git-Tag: v9.1.2120^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=611d7e19f7226d0b6b6be90e7623820feb9a0ca0;p=thirdparty%2Fvim.git patch 9.1.2120: blob2str() does not restore trailing newline Problem: blob2str() does not restore trailing newline Solution: Append empty string (thinca). closes: #19288 Signed-off-by: thinca Signed-off-by: Christian Brabandt --- diff --git a/src/strings.c b/src/strings.c index 782249fb75..4d878cb7db 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1359,6 +1359,10 @@ f_blob2str(typval_T *argvars, typval_T *rettv) break; } + // If the blob ends with a newline, we need to add another empty string. + if (blen > 0 && blob_get(blob, blen - 1) == NL) + list_append_string(rettv->vval.v_list, (char_u *)"", 0); + done: vim_free(from_encoding); } diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 9dba0b3f31..2fa09eddc0 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -4512,6 +4512,7 @@ func Test_blob2str() call assert_equal(["ab"], blob2str(0z6162)) call assert_equal(["a\nb"], blob2str(0z610062)) call assert_equal(["ab", "cd"], blob2str(0z61620A6364)) + call assert_equal(["ab", "cd", ""], blob2str(0z61620A63640A)) call assert_equal(["«»"], blob2str(0zC2ABC2BB)) call assert_equal(["ŝş"], blob2str(0zC59DC59F)) diff --git a/src/version.c b/src/version.c index b52290a859..94b463ebe0 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 */ +/**/ + 2120, /**/ 2119, /**/