mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #17334 from zeertzjq/vim-8.2.4326
vim-patch:8.2.4326: "o" and "O" copying comment not sufficiently tested
This commit is contained in:
commit
1a5e893cee
@ -1201,10 +1201,10 @@ 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 && dir == FORWARD) {
|
if (flags & OPENLINE_DO_COM) {
|
||||||
// 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 && 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,
|
||||||
|
@ -238,7 +238,33 @@ func Test_format_c_comment()
|
|||||||
END
|
END
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
|
||||||
" Using "o" repeats the line comment, "O" does not.
|
" Using either "o" or "O" repeats a line comment occupying a whole line.
|
||||||
|
%del
|
||||||
|
let text =<< trim END
|
||||||
|
nop;
|
||||||
|
// This is a comment
|
||||||
|
val = val;
|
||||||
|
END
|
||||||
|
call setline(1, text)
|
||||||
|
normal 2Go
|
||||||
|
let expected =<< trim END
|
||||||
|
nop;
|
||||||
|
// This is a comment
|
||||||
|
//
|
||||||
|
val = val;
|
||||||
|
END
|
||||||
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
normal 2GO
|
||||||
|
let expected =<< trim END
|
||||||
|
nop;
|
||||||
|
//
|
||||||
|
// This is a comment
|
||||||
|
//
|
||||||
|
val = val;
|
||||||
|
END
|
||||||
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
|
||||||
|
" Using "o" repeats a line comment after a statement, "O" does not.
|
||||||
%del
|
%del
|
||||||
let text =<< trim END
|
let text =<< trim END
|
||||||
nop;
|
nop;
|
||||||
|
Loading…
Reference in New Issue
Block a user