diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-29 15:15:47 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-29 15:15:47 +0000 |
commit | 5ea5f373729589acb38ce3f3ca338e8a6d398bdc (patch) | |
tree | c733ac730be8d8b3be053a2137ac2aa9daf86757 /src | |
parent | 3d0abad5bf4fe125e219f1b56c4e8200cb900e2a (diff) |
patch 8.2.3934: repeating line comment is undesired for "O" commandv8.2.3934
Problem: Repeating line comment is undesired for "O" command.
Solution: Do not copy line comment leader for "O". (closes #9426)
Diffstat (limited to 'src')
-rw-r--r-- | src/change.c | 5 | ||||
-rw-r--r-- | src/testdir/test_textformat.vim | 23 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 28 insertions, 2 deletions
diff --git a/src/change.c b/src/change.c index 1e008a4b00..bc77fa23da 100644 --- a/src/change.c +++ b/src/change.c @@ -1655,13 +1655,14 @@ open_line( lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, TRUE); #ifdef FEAT_CINDENT - if (lead_len == 0 && do_cindent) + if (lead_len == 0 && do_cindent && dir == FORWARD) { + // Check for a line comment after code. comment_start = check_linecomment(saved_line); if (comment_start != MAXCOL) { lead_len = get_leader_len(saved_line + comment_start, - &lead_flags, dir == BACKWARD, TRUE); + &lead_flags, FALSE, TRUE); if (lead_len != 0) { lead_len += comment_start; diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim index 07a9224c6b..1a7bb68728 100644 --- a/src/testdir/test_textformat.vim +++ b/src/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 diff --git a/src/version.c b/src/version.c index 2b1ce02d50..e4b481bf27 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3934, +/**/ 3933, /**/ 3932, |