Patch 8.2.4908
Problem:    No text formatting for // comment after a statement.
Solution:   format a comment when the 'c' flag is in 'formatoptions'.
Files:      src/textformat.c, src/testdir/test_textformat.vim


*** ../vim-8.2.4907/src/textformat.c    2022-01-22 19:17:27.219225083 +0000
--- src/textformat.c    2022-05-07 15:25:23.022349899 +0100
***************
*** 104,110 ****
  
        // Don't break until after the comment leader
        if (do_comments)
!           leader_len = get_leader_len(ml_get_curline(), NULL, FALSE, TRUE);
        else
            leader_len = 0;
  
--- 104,130 ----
  
        // Don't break until after the comment leader
        if (do_comments)
!       {
!           char_u *line = ml_get_curline();
! 
!           leader_len = get_leader_len(line, NULL, FALSE, TRUE);
! #ifdef FEAT_CINDENT
!           if (leader_len == 0 && curbuf->b_p_cin)
!           {
!               int             comment_start;
! 
!               // Check for a line comment after code.
!               comment_start = check_linecomment(line);
!               if (comment_start != MAXCOL)
!               {
!                   leader_len = get_leader_len(
!                                     line + comment_start, NULL, FALSE, TRUE);
!                   if (leader_len != 0)
!                       leader_len += comment_start;
!               }
!           }
! #endif
!       }
        else
            leader_len = 0;
  
*** ../vim-8.2.4907/src/testdir/test_textformat.vim     2022-05-07 
14:53:40.443628505 +0100
--- src/testdir/test_textformat.vim     2022-05-07 15:42:43.837799095 +0100
***************
*** 342,347 ****
--- 342,359 ----
    END
    call assert_equal(expected, getline(1, '$'))
  
+   " typing comment text auto-wraps
+   %del
+   call setline(1, text)
+   exe "normal! 2GA blah more text blah.\<Esc>"
+   let expected =<< trim END
+       {
+          val = val;      // This is a comment
+                          // blah more text
+                          // blah.
+   END
+   call assert_equal(expected, getline(1, '$'))
+ 
    bwipe!
  endfunc
  
*** ../vim-8.2.4907/src/version.c       2022-05-07 14:53:40.443628505 +0100
--- src/version.c       2022-05-07 15:30:36.918165281 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4908,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
127. You bring your laptop and cellular phone to church.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220507144430.AF2D41C0463%40moolenaar.net.

Raspunde prin e-mail lui