# HG changeset patch # User Bram Moolenaar # Date 1573587904 -3600 # Node ID 9cbdd58eeeb2f708dd8d8835153d46203a60ed7d # Parent 8ad5734bb66b4af54b21b96036e3ee6614f59ec3 patch 8.1.2293: join adds trailing space when second line is empty Commit: https://github.com/vim/vim/commit/cc184cfb09161b3bbc7d5d8859a18e812367d19c Author: Bram Moolenaar Date: Tue Nov 12 20:31:20 2019 +0100 patch 8.1.2293: join adds trailing space when second line is empty Problem: Join adds trailing space when second line is empty. (Brennan Vincent) Solution: Do not add a trailing space. diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -1999,7 +1999,8 @@ do_join( if (insert_space && t > 0) { curr = skipwhite(curr); - if (*curr != ')' && currsize != 0 && endcurr1 != TAB + if (*curr != NUL && *curr != ')' + && currsize != 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 @@ -9,6 +9,27 @@ func Test_join_with_count() call setline(1, ['one', 'two', 'three', 'four']) normal 10J call assert_equal('one two three four', getline(1)) + + call setline(1, ['one', '', 'two']) + normal J + call assert_equal('one', getline(1)) + + call setline(1, ['one', ' ', 'two']) + normal J + call assert_equal('one', getline(1)) + + call setline(1, ['one', '', '', 'two']) + normal JJ + call assert_equal('one', getline(1)) + + call setline(1, ['one', ' ', ' ', 'two']) + normal JJ + call assert_equal('one', getline(1)) + + call setline(1, ['one', '', '', 'two']) + normal 2J + call assert_equal('one', getline(1)) + quit! endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2293, +/**/ 2292, /**/ 2291,