diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-12 14:16:39 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-12 14:16:39 +0000 |
commit | 6e371ecb27227ff8fedd8561d0f3880a17576848 (patch) | |
tree | 29129df4da69f0093ac1b763dffb2be45e84c587 /src/testdir | |
parent | 9a4ec5a62632af040c278a189e256043740f5c7f (diff) |
patch 8.2.3787: no proper formatting of a C line comment after a statementv8.2.3787
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.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_cindent.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_textformat.vim | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim index c097ca766d..c7ce2babe2 100644 --- a/src/testdir/test_cindent.vim +++ b/src/testdir/test_cindent.vim @@ -1694,9 +1694,9 @@ func Test_cindent_1() #endif int y; // comment - // comment + // comment - // comment + // comment { Constructor(int a, diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim index 2b76292777..62cefa1a0f 100644 --- a/src/testdir/test_textformat.vim +++ b/src/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! |