# HG changeset patch # User Bram Moolenaar # Date 1649695502 -7200 # Node ID ef62a0ea2a78241beeccdb0ccc1b75c932406769 # Parent 6c275c41f7e5175bb06e83198f063e5ef3913d3c patch 8.2.4737: // in JavaScript string recognized as comment Commit: https://github.com/vim/vim/commit/1655619717ff109ea8bf1002883636d5af345e48 Author: Bram Moolenaar Date: Mon Apr 11 17:36:37 2022 +0100 patch 8.2.4737: // in JavaScript string recognized as comment Problem: // in JavaScript string recognized as comment. Solution: Only check for linecomment if 'cindent' is set. (closes https://github.com/vim/vim/issues/10151) diff --git a/src/change.c b/src/change.c --- a/src/change.c +++ b/src/change.c @@ -1659,7 +1659,7 @@ open_line( lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, TRUE); #ifdef FEAT_CINDENT - if (lead_len == 0 && do_cindent && dir == FORWARD) + if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD) { // Check for a line comment after code. comment_start = check_linecomment(saved_line); diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim --- a/src/testdir/test_textformat.vim +++ b/src/testdir/test_textformat.vim @@ -278,12 +278,25 @@ func Test_format_c_comment() // END call assert_equal(expected, getline(1, '$')) + + " using 'indentexpr' instead of 'cindent' does not repeat a comment + setl nocindent indentexpr=2 + 3delete + normal 2Gox + let expected =<< trim END + nop; + val = val; // This is a comment + x + END + call assert_equal(expected, getline(1, '$')) + setl cindent indentexpr= + 3delete + normal 2GO let expected =<< trim END nop; val = val; // This is a comment - // END call assert_equal(expected, getline(1, '$')) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4737, +/**/ 4736, /**/ 4735,