Patch 8.2.3932
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.
Files: src/textformat.c, src/testdir/test_textformat.vim
*** ../vim-8.2.3931/src/textformat.c 2021-12-27 17:21:38.020449109 +0000
--- src/textformat.c 2021-12-29 14:04:35.921226116 +0000
***************
*** 193,199 ****
if (curwin->w_cursor.col <= (colnr_T)wantcol)
break;
}
! else if ((cc >= 0x100 || !utf_allow_break_before(cc)) && fo_multibyte)
{
int ncc;
int allow_break;
--- 193,200 ----
if (curwin->w_cursor.col <= (colnr_T)wantcol)
break;
}
! else if ((cc >= 0x100 || !utf_allow_break_before(cc))
! && fo_multibyte)
{
int ncc;
int allow_break;
***************
*** 948,954 ****
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
int do_comments; // format comments
int do_comments_list = 0; // format comments with 'n' or '2'
int advance = TRUE;
--- 949,955 ----
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 = NULL; // flags for leader of next line
int do_comments; // format comments
int do_comments_list = 0; // format comments with 'n' or '2'
int advance = TRUE;
***************
*** 1071,1077 ****
--- 1072,1086 ----
|| !same_leader(curwin->w_cursor.lnum,
leader_len, leader_flags,
next_leader_len, next_leader_flags))
+ {
+ // 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(ml_get_curline()) == MAXCOL)
is_end_par = TRUE;
+ }
// If we have got to the end of a paragraph, or the line is
// getting long, format it.
*** ../vim-8.2.3931/src/testdir/test_textformat.vim 2021-12-12 14:16:34.993862200 +0000
--- src/testdir/test_textformat.vim 2021-12-29 14:06:04.321049459 +0000
***************
*** 223,228 ****
--- 223,243 ----
END
call assert_equal(expected, getline(1, '$'))
+ %del
+ let text =<< trim END
+ #if 0 // This is another long end of
+ // line comment that
+ // wraps.
+ END
+ call setline(1, text)
+ normal gq2j
+ let expected =<< trim END
+ #if 0 // This is another long
+ // end of line comment
+ // that wraps.
+ END
+ call assert_equal(expected, getline(1, '$'))
+
bwipe!
endfunc
*** ../vim-8.2.3931/src/version.c 2021-12-29 11:59:48.375822066 +0000
--- src/version.c 2021-12-29 14:08:55.672723862 +0000
***************
*** 751,752 ****
--- 751,754 ----
{ /* Add new patch number below this line */
+ /**/
+ 3932,
/**/
--
hundred-and-one symptoms of being an internet addict:
137. You decide to stay in college for an additional year or two,
just so you can have the free Internet access.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///