From eda957db10e97b28a2734e0391d986676927d963 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 31 Jan 2022 15:44:54 +0800 Subject: vim-patch:8.2.3787: no proper formatting of a C line comment after a statement Problem: No proper formatting of a C line comment after a statement. Solution: Find the start of the line comment, insert the comment leader and indent the comment properly. https://github.com/vim/vim/commit/6e371ecb27227ff8fedd8561d0f3880a17576848 --- src/nvim/testdir/test_cindent.vim | 4 ++-- src/nvim/testdir/test_textformat.vim | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim index 6554d034d3..5dc54111e7 100644 --- a/src/nvim/testdir/test_cindent.vim +++ b/src/nvim/testdir/test_cindent.vim @@ -1707,9 +1707,9 @@ func Test_cindent_1() #endif int y; // comment - // comment + // comment - // comment + // comment { Constructor(int a, diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index bf0706a0c2..5ca2554218 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -196,6 +196,36 @@ func Test_text_format() enew! endfunc +func Test_format_c_comment() + new + setl ai cindent tw=40 et fo=croql + let text =<< trim END + var = 2345; // asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf + END + call setline(1, text) + normal gql + let expected =<< trim END + var = 2345; // asdf asdf asdf asdf asdf + // asdf asdf asdf asdf asdf + END + call assert_equal(expected, getline(1, '$')) + + %del + let text =<< trim END + var = 2345; // asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf + END + call setline(1, text) + normal gql + let expected =<< trim END + var = 2345; // asdf asdf asdf asdf asdf + // asdf asdf asdf asdf asdf + // asdf asdf + END + call assert_equal(expected, getline(1, '$')) + + bwipe! +endfunc + " Tests for :right, :center and :left on text with embedded TAB. func Test_format_align() enew! -- cgit From 88ba0774e202126a432521d5cb14bd2187ef65a2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 31 Jan 2022 15:44:54 +0800 Subject: vim-patch:8.2.3932: C line comment not formatted properly Problem: C line comment not formatted properly. Solution: If a line comment follows after "#if" the next line is not the end of a paragraph. https://github.com/vim/vim/commit/264d3ddac0f9474816c20a0e92014d6f7f4b08ac --- src/nvim/testdir/test_textformat.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index 5ca2554218..25ae208f03 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -223,6 +223,21 @@ func Test_format_c_comment() END call assert_equal(expected, getline(1, '$')) + %del + let text =<< trim END + #if 0 // This is another long end of + // line comment that + // wraps. + END + call setline(1, text) + normal gq2j + let expected =<< trim END + #if 0 // This is another long + // end of line comment + // that wraps. + END + call assert_equal(expected, getline(1, '$')) + bwipe! endfunc -- cgit From da3b04a9e07635bab9b0d67e9b16c62c1e59e004 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 31 Jan 2022 15:44:54 +0800 Subject: vim-patch:8.2.3934: repeating line comment is undesired for "O" command Problem: Repeating line comment is undesired for "O" command. Solution: Do not copy line comment leader for "O". (closes vim/vim#9426) https://github.com/vim/vim/commit/5ea5f373729589acb38ce3f3ca338e8a6d398bdc --- src/nvim/testdir/test_textformat.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index 25ae208f03..5cebdef7f1 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -238,6 +238,29 @@ func Test_format_c_comment() END call assert_equal(expected, getline(1, '$')) + " Using "o" repeates the line comment, "O" does not. + %del + let text =<< trim END + nop; + val = val; // This is a comment + END + call setline(1, text) + normal 2Go + let expected =<< trim END + nop; + val = val; // This is a comment + // + END + call assert_equal(expected, getline(1, '$')) + normal 2GO + let expected =<< trim END + nop; + + val = val; // This is a comment + // + END + call assert_equal(expected, getline(1, '$')) + bwipe! endfunc -- cgit From f7801fe138d9677c9333650b4d5581489d4b0613 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 31 Jan 2022 15:44:54 +0800 Subject: vim-patch:8.2.3935: CTRL-U in Insert mode does not fix the indent Problem: CTRL-U in Insert mode does not fix the indent. Solution: Fix the indent when 'cindent' is set. https://github.com/vim/vim/commit/5d20fbf2e79b96a39abbdadc486b656cdcc67ed6 --- src/nvim/testdir/test_textformat.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index 5cebdef7f1..e1d155eba7 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -238,7 +238,7 @@ func Test_format_c_comment() END call assert_equal(expected, getline(1, '$')) - " Using "o" repeates the line comment, "O" does not. + " Using "o" repeats the line comment, "O" does not. %del let text =<< trim END nop; @@ -261,6 +261,21 @@ func Test_format_c_comment() END call assert_equal(expected, getline(1, '$')) + " Using CTRL-U after "o" fixes the indent + %del + let text =<< trim END + { + val = val; // This is a comment + END + call setline(1, text) + exe "normal! 2Go\x\" + let expected =<< trim END + { + val = val; // This is a comment + x + END + call assert_equal(expected, getline(1, '$')) + bwipe! endfunc -- cgit From ae649650de3509e22ee6fad5cfa72998d40f2a92 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 31 Jan 2022 15:44:54 +0800 Subject: vim-patch:8.2.3938: line comment start is also found in a string Problem: Line comment start is also found in a string. Solution: Skip line comments in a string. https://github.com/vim/vim/commit/ba26367fea3b63df49d274f3d5cca0af38402add --- src/nvim/testdir/test_textformat.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index e1d155eba7..052c32214d 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -261,6 +261,21 @@ func Test_format_c_comment() END call assert_equal(expected, getline(1, '$')) + " Using "o" does not repeat a comment in a string + %del + let text =<< trim END + nop; + val = " // This is not a comment"; + END + call setline(1, text) + normal 2Gox + let expected =<< trim END + nop; + val = " // This is not a comment"; + x + END + call assert_equal(expected, getline(1, '$')) + " Using CTRL-U after "o" fixes the indent %del let text =<< trim END -- cgit