1
0
forked from aniani/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 #9426)
This commit is contained in:
Bram Moolenaar
2021-12-29 15:15:47 +00:00
parent 3d0abad5bf
commit 5ea5f37372
3 changed files with 28 additions and 2 deletions

View File

@@ -1655,13 +1655,14 @@ open_line(
lead_len = get_leader_len(saved_line, &lead_flags, lead_len = get_leader_len(saved_line, &lead_flags,
dir == BACKWARD, TRUE); dir == BACKWARD, TRUE);
#ifdef FEAT_CINDENT #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); comment_start = check_linecomment(saved_line);
if (comment_start != MAXCOL) if (comment_start != MAXCOL)
{ {
lead_len = get_leader_len(saved_line + comment_start, lead_len = get_leader_len(saved_line + comment_start,
&lead_flags, dir == BACKWARD, TRUE); &lead_flags, FALSE, TRUE);
if (lead_len != 0) if (lead_len != 0)
{ {
lead_len += comment_start; lead_len += comment_start;

View File

@@ -238,6 +238,29 @@ func Test_format_c_comment()
END END
call assert_equal(expected, getline(1, '$')) 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! bwipe!
endfunc endfunc

View File

@@ -749,6 +749,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3934,
/**/ /**/
3933, 3933,
/**/ /**/