summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-04-11 17:36:37 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-11 17:36:37 +0100
commit1655619717ff109ea8bf1002883636d5af345e48 (patch)
tree56c67651f11728e39f65ec2a52e85187d983db42 /src
parent825b55e695b842beb6515ec5c53583aac9efe7b7 (diff)
downloadvim-git-1655619717ff109ea8bf1002883636d5af345e48.tar.gz
patch 8.2.4737: // in JavaScript string recognized as commentv8.2.4737
Problem: // in JavaScript string recognized as comment. Solution: Only check for linecomment if 'cindent' is set. (closes #10151)
Diffstat (limited to 'src')
-rw-r--r--src/change.c2
-rw-r--r--src/testdir/test_textformat.vim15
-rw-r--r--src/version.c2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/change.c b/src/change.c
index bc9195be4..259f07664 100644
--- 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
index 385021396..1d4ade9b7 100644
--- 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
index 737b54b91..f1199839d 100644
--- 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,