Commit: patch 9.1.2120: blob2str() does not restore trailing newline

0 views
Skip to first unread message

Christian Brabandt

unread,
Jan 31, 2026, 5:01:26 AMJan 31
to vim...@googlegroups.com
patch 9.1.2120: blob2str() does not restore trailing newline

Commit: https://github.com/vim/vim/commit/611d7e19f7226d0b6b6be90e7623820feb9a0ca0
Author: thinca <thi...@gmail.com>
Date: Sat Jan 31 09:52:00 2026 +0000

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 <thi...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/strings.c b/src/strings.c
index 782249fb7..4d878cb7d 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 9dba0b3f3..2fa09eddc 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
b"], 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 b52290a85..94b463ebe 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,
/**/
Reply all
Reply to author
Forward
0 new messages