]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0018: :join does not add white space where it should v8.2.0018
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Dec 2019 21:10:58 +0000 (22:10 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Dec 2019 21:10:58 +0000 (22:10 +0100)
Problem:    :join does not add white space where it should. (Zdenek Dohnal)
Solution:   Handle joining multiple lines propely.

src/ops.c
src/testdir/test_join.vim
src/version.c

index 2a625066c45173ffb3b8f21b106cc42314db1476..72ffd56bc9b40ca581b068e60830bc3418966cc8 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -2001,7 +2001,7 @@ do_join(
        {
            curr = skipwhite(curr);
            if (*curr != NUL && *curr != ')'
-                   && currsize != 0 && endcurr1 != TAB
+                   && sumsize != 0 && endcurr1 != TAB
                    && (!has_format_option(FO_MBYTE_JOIN)
                        || (mb_ptr2char(curr) < 0x100 && endcurr1 < 0x100))
                    && (!has_format_option(FO_MBYTE_JOIN2)
index 5801c2f1274a5d9fb2d868f4fd14181eee65ea98..377edab1e969010cd6128b0e9dbc06a41256ff8b 100644 (file)
@@ -427,3 +427,14 @@ int i = 7 /* foo *// 3
   call assert_equal(expected, getline(1, '$'))
   close!
 endfunc
+
+func Test_join_lines()
+  new
+  call setline(1, ['a', 'b', '', 'c', 'd'])
+  %join
+  call assert_equal('a b c d', getline(1))
+  call setline(1, ['a', 'b', '', 'c', 'd'])
+  normal 5J
+  call assert_equal('a b c d', getline(1))
+  bwipe!
+endfunc
index c11710a6b6e2d93548643dfc2f1a3f0fc975ec25..65924cd09772de19cfd3d894f6ed93679081df16 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    18,
 /**/
     17,
 /**/