Problem: Vim9: error for #{{ is not desired.
Solution: Adjust the checks. (closes #7990)
EXTERN char e_import_as_name_not_supported_here[]
INIT(= N_("E1169: 'import * as {name}' not supported here"));
EXTERN char e_cannot_use_hash_curly_to_start_comment[]
- INIT(= N_("E1170: 'Cannot use #{ to start a comment"));
+ INIT(= N_("E1170: Cannot use #{ to start a comment"));
return TRUE;
#ifdef FEAT_EVAL
if (in_vim9script())
- return c == '#' && cmd[1] != '{'
+ // # starts a comment, #{ might be a mistake, #{{ can start a fold
+ return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
&& (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
#endif
return c == '"';
# automatic conversion from number to string
var n = 123
var dictnr = {[n]: 1}
+
+ # comment to start fold is OK
+ var x1: number #{{ fold
+ var x2 = 9 #{{ fold
END
CheckDefAndScriptSuccess(lines)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2629,
/**/
2628,
/**/
int
vim9_bad_comment(char_u *p)
{
- if (p[0] == '#' && p[1] == '{')
+ if (p[0] == '#' && p[1] == '{' && p[2] != '{')
{
emsg(_(e_cannot_use_hash_curly_to_start_comment));
return TRUE;
}
/*
- * Return TRUE if "p" points at a "#" not followed by '{'.
+ * Return TRUE if "p" points at a "#" not followed by one '{'.
* Does not check for white space.
*/
int
vim9_comment_start(char_u *p)
{
- return p[0] == '#' && p[1] != '{';
+ return p[0] == '#' && (p[1] != '{' || p[2] == '{');
}
#if defined(FEAT_EVAL) || defined(PROTO)