Skip to content

Commit a0399ef

Browse files
committed
patch 8.2.2629: Vim9: error for #{{ is not desired
Problem: Vim9: error for #{{ is not desired. Solution: Adjust the checks. (closes #7990)
1 parent 5c7a299 commit a0399ef

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/errors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,4 @@ EXTERN char e_argument_already_declared_in_script_str[]
376376
EXTERN char e_import_as_name_not_supported_here[]
377377
INIT(= N_("E1169: 'import * as {name}' not supported here"));
378378
EXTERN char e_cannot_use_hash_curly_to_start_comment[]
379-
INIT(= N_("E1170: 'Cannot use #{ to start a comment"));
379+
INIT(= N_("E1170: Cannot use #{ to start a comment"));

src/ex_docmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5234,7 +5234,8 @@ ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
52345234
return TRUE;
52355235
#ifdef FEAT_EVAL
52365236
if (in_vim9script())
5237-
return c == '#' && cmd[1] != '{'
5237+
// # starts a comment, #{ might be a mistake, #{{ can start a fold
5238+
return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
52385239
&& (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
52395240
#endif
52405241
return c == '"';

src/testdir/test_vim9_expr.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,10 @@ def Test_expr7_dict()
21552155
# automatic conversion from number to string
21562156
var n = 123
21572157
var dictnr = {[n]: 1}
2158+
2159+
# comment to start fold is OK
2160+
var x1: number #{{ fold
2161+
var x2 = 9 #{{ fold
21582162
END
21592163
CheckDefAndScriptSuccess(lines)
21602164

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2629,
753755
/**/
754756
2628,
755757
/**/

src/vim9script.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ not_in_vim9(exarg_T *eap)
120120
int
121121
vim9_bad_comment(char_u *p)
122122
{
123-
if (p[0] == '#' && p[1] == '{')
123+
if (p[0] == '#' && p[1] == '{' && p[2] != '{')
124124
{
125125
emsg(_(e_cannot_use_hash_curly_to_start_comment));
126126
return TRUE;
@@ -129,13 +129,13 @@ vim9_bad_comment(char_u *p)
129129
}
130130

131131
/*
132-
* Return TRUE if "p" points at a "#" not followed by '{'.
132+
* Return TRUE if "p" points at a "#" not followed by one '{'.
133133
* Does not check for white space.
134134
*/
135135
int
136136
vim9_comment_start(char_u *p)
137137
{
138-
return p[0] == '#' && p[1] != '{';
138+
return p[0] == '#' && (p[1] != '{' || p[2] == '{');
139139
}
140140

141141
#if defined(FEAT_EVAL) || defined(PROTO)

0 commit comments

Comments
 (0)