patch 8.2.3787: no proper formatting of a C line comment after a statement
Problem: No proper formatting of a C line comment after a statement.
Solution: Find the start of the line comment, insert the comment leader and
indent the comment properly.
diff --git a/src/textformat.c b/src/textformat.c
index fb2ca95..58ba0ab 100644
--- a/src/textformat.c
+++ b/src/textformat.c
@@ -89,6 +89,7 @@
colnr_T col;
colnr_T end_col;
int wcc; // counter for whitespace chars
+ int did_do_comment = FALSE;
virtcol = get_nolist_virtcol()
+ char2cells(c != NUL ? c : gchar_cursor());
@@ -352,10 +353,16 @@
+ (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
+ (do_comments ? OPENLINE_DO_COM : 0)
+ ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0)
- , ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent));
+ , ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent),
+ &did_do_comment);
if (!(flags & INSCHAR_COM_LIST))
old_indent = 0;
+ // If a comment leader was inserted, may also do this on a following
+ // line.
+ if (did_do_comment)
+ no_leader = FALSE;
+
replace_offset = 0;
if (first_line)
{