Patch 8.2.3934
Problem: Repeating line comment is undesired for "O" command.
Solution: Do not copy line comment leader for "O". (closes #9426)
Files: src/change.c, src/testdir/test_textformat.vim
*** ../vim-8.2.3933/src/change.c 2021-12-13 13:11:00.688262353 +0000
--- src/change.c 2021-12-29 15:07:56.995868957 +0000
***************
*** 1655,1667 ****
lead_len = get_leader_len(saved_line, &lead_flags,
dir == BACKWARD, TRUE);
#ifdef FEAT_CINDENT
! if (lead_len == 0 && do_cindent)
{
comment_start = check_linecomment(saved_line);
if (comment_start != MAXCOL)
{
lead_len = get_leader_len(saved_line + comment_start,
! &lead_flags, dir == BACKWARD, TRUE);
if (lead_len != 0)
{
lead_len += comment_start;
--- 1655,1668 ----
lead_len = get_leader_len(saved_line, &lead_flags,
dir == BACKWARD, TRUE);
#ifdef FEAT_CINDENT
! if (lead_len == 0 && do_cindent && dir == FORWARD)
{
+ // Check for a line comment after code.
comment_start = check_linecomment(saved_line);
if (comment_start != MAXCOL)
{
lead_len = get_leader_len(saved_line + comment_start,
! &lead_flags, FALSE, TRUE);
if (lead_len != 0)
{
lead_len += comment_start;
*** ../vim-8.2.3933/src/testdir/test_textformat.vim 2021-12-29
14:09:28.636663343 +0000
--- src/testdir/test_textformat.vim 2021-12-29 15:14:59.607275143 +0000
***************
*** 238,243 ****
--- 238,266 ----
END
call assert_equal(expected, getline(1, '$'))
+ " Using "o" repeates the line comment, "O" does not.
+ %del
+ let text =<< trim END
+ nop;
+ val = val; // This is a comment
+ END
+ call setline(1, text)
+ normal 2Go
+ let expected =<< trim END
+ nop;
+ val = val; // This is a comment
+ //
+ END
+ call assert_equal(expected, getline(1, '$'))
+ normal 2GO
+ let expected =<< trim END
+ nop;
+
+ val = val; // This is a comment
+ //
+ END
+ call assert_equal(expected, getline(1, '$'))
+
bwipe!
endfunc
*** ../vim-8.2.3933/src/version.c 2021-12-29 14:39:04.634256171 +0000
--- src/version.c 2021-12-29 15:08:34.099817128 +0000
***************
*** 751,752 ****
--- 751,754 ----
{ /* Add new patch number below this line */
+ /**/
+ 3934,
/**/
--
Amazing but true: If all the salmon caught in Canada in one year were laid
end to end across the Sahara Desert, the smell would be absolutely awful.
/// 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/20211229151620.819D11C0641%40moolenaar.net.