patch 9.1.2120: blob2str() does not restore trailing newline

Commit: 
https://github.com/vim/vim/commit/611d7e19f7226d0b6b6be90e7623820feb9a0ca0
Author: thinca <[email protected]>
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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vm7lr-005MRx-H2%40256bit.org.

Raspunde prin e-mail lui