aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-01-31 15:44:54 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-01-31 15:44:54 +0800
commit88ba0774e202126a432521d5cb14bd2187ef65a2 (patch)
treeeca5f0142ffb0b0318a9d9087dbaad6195884c02 /src/nvim/ops.c
parenteda957db10e97b28a2734e0391d986676927d963 (diff)
downloadrneovim-88ba0774e202126a432521d5cb14bd2187ef65a2.tar.gz
rneovim-88ba0774e202126a432521d5cb14bd2187ef65a2.tar.bz2
rneovim-88ba0774e202126a432521d5cb14bd2187ef65a2.zip
vim-patch:8.2.3932: C line comment not formatted properly
Problem: C line comment not formatted properly. Solution: If a line comment follows after "#if" the next line is not the end of a paragraph. https://github.com/vim/vim/commit/264d3ddac0f9474816c20a0e92014d6f7f4b08ac
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 83a7c31991..11484eee57 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -4350,7 +4350,7 @@ void format_lines(linenr_T line_count, int avoid_fex)
int leader_len = 0; // leader len of current line
int next_leader_len; // leader len of next line
char_u *leader_flags = NULL; // flags for leader of current line
- char_u *next_leader_flags; // flags for leader of next line
+ char_u *next_leader_flags = NULL; // flags for leader of next line
bool advance = true;
int second_indent = -1; // indent for second line (comment aware)
bool first_par_line = true;
@@ -4467,7 +4467,14 @@ void format_lines(linenr_T line_count, int avoid_fex)
leader_len, leader_flags,
next_leader_len,
next_leader_flags)) {
- is_end_par = true;
+ // Special case: If the next line starts with a line comment
+ // and this line has a line comment after some text, the
+ // paragraph doesn't really end.
+ if (next_leader_flags == NULL
+ || STRNCMP(next_leader_flags, "://", 3) != 0
+ || check_linecomment(get_cursor_line_ptr()) == MAXCOL) {
+ is_end_par = true;
+ }
}
/*