mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
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 #10151)
This commit is contained in:
@@ -1659,7 +1659,7 @@ open_line(
|
|||||||
lead_len = get_leader_len(saved_line, &lead_flags,
|
lead_len = get_leader_len(saved_line, &lead_flags,
|
||||||
dir == BACKWARD, TRUE);
|
dir == BACKWARD, TRUE);
|
||||||
#ifdef FEAT_CINDENT
|
#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.
|
// Check for a line comment after code.
|
||||||
comment_start = check_linecomment(saved_line);
|
comment_start = check_linecomment(saved_line);
|
||||||
|
@@ -278,12 +278,25 @@ func Test_format_c_comment()
|
|||||||
//
|
//
|
||||||
END
|
END
|
||||||
call assert_equal(expected, getline(1, '$'))
|
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
|
normal 2GO
|
||||||
let expected =<< trim END
|
let expected =<< trim END
|
||||||
nop;
|
nop;
|
||||||
|
|
||||||
val = val; // This is a comment
|
val = val; // This is a comment
|
||||||
//
|
|
||||||
END
|
END
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4737,
|
||||||
/**/
|
/**/
|
||||||
4736,
|
4736,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user