# HG changeset patch # User Bram Moolenaar # Date 1576617304 -3600 # Node ID 4c0b420e73270138ad3b93cc69abf03e4ebaf4df # Parent 35d2ab3c4ff673f63b0d825a8a8181df73b474bc patch 8.2.0018: :join does not add white space where it should Commit: https://github.com/vim/vim/commit/91b65e49440e77222a65b6f868507453239f409b Author: Bram Moolenaar Date: Tue Dec 17 22:10:58 2019 +0100 patch 8.2.0018: :join does not add white space where it should Problem: :join does not add white space where it should. (Zdenek Dohnal) Solution: Handle joining multiple lines propely. diff --git a/src/ops.c b/src/ops.c --- 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) diff --git a/src/testdir/test_join.vim b/src/testdir/test_join.vim --- a/src/testdir/test_join.vim +++ b/src/testdir/test_join.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 18, +/**/ 17, /**/ 16,