mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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)
5ea5f37372
This commit is contained in:
parent
88ba0774e2
commit
da3b04a9e0
@ -1201,13 +1201,14 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
|||||||
// Find out if the current line starts with a comment leader.
|
// Find out if the current line starts with a comment leader.
|
||||||
// This may then be inserted in front of the new line.
|
// This may then be inserted in front of the new line.
|
||||||
end_comment_pending = NUL;
|
end_comment_pending = NUL;
|
||||||
if (flags & OPENLINE_DO_COM) {
|
if (flags & OPENLINE_DO_COM && dir == FORWARD) {
|
||||||
|
// Check for a line comment after code.
|
||||||
lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, true);
|
lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, true);
|
||||||
if (lead_len == 0 && do_cindent) {
|
if (lead_len == 0 && do_cindent) {
|
||||||
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;
|
||||||
if (did_do_comment != NULL) {
|
if (did_do_comment != NULL) {
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user