0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

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.
This commit is contained in:
Bram Moolenaar
2021-12-12 14:16:39 +00:00
parent 9a4ec5a626
commit 6e371ecb27
11 changed files with 118 additions and 24 deletions

View File

@@ -89,6 +89,7 @@ internal_format(
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 @@ internal_format(
+ (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)
{