From 0cb6fc804dbf7b46772ea14e8c7b40909b97202c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 12 Nov 2019 20:04:15 -0500 Subject: vim-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. https://github.com/vim/vim/commit/cc184cfb09161b3bbc7d5d8859a18e812367d19c --- src/nvim/ops.c | 5 ++++- src/nvim/testdir/test_join.vim | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 95674f8b40..2301b2159f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3773,7 +3773,10 @@ int do_join(size_t count, 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) || (utf_ptr2char(curr) < 0x100 && endcurr1 < 0x100)) && (!has_format_option(FO_MBYTE_JOIN2) diff --git a/src/nvim/testdir/test_join.vim b/src/nvim/testdir/test_join.vim index 1c97414164..ecb55c9af6 100644 --- a/src/nvim/testdir/test_join.vim +++ b/src/nvim/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 -- cgit