]> granicus.if.org Git - vim/commitdiff
patch 8.2.2629: Vim9: error for #{{ is not desired v8.2.2629
authorBram Moolenaar <Bram@vim.org>
Sat, 20 Mar 2021 14:00:01 +0000 (15:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 20 Mar 2021 14:00:01 +0000 (15:00 +0100)
Problem:    Vim9: error for #{{ is not desired.
Solution:   Adjust the checks. (closes #7990)

src/errors.h
src/ex_docmd.c
src/testdir/test_vim9_expr.vim
src/version.c
src/vim9script.c

index ed55304bc4053acc9274f1f0d3d9c8872646b816..e5c9d8e9926ea9e39c5af8d62cb4b7e69f96be69 100644 (file)
@@ -376,4 +376,4 @@ EXTERN char e_argument_already_declared_in_script_str[]
 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"));
index 67bcc7370e57011260494b6bc32fd01f3275490e..d82d2b8769ea0b5a003a04285d56e2af7a15aa82 100644 (file)
@@ -5234,7 +5234,8 @@ ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
        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 == '"';
index de6eabd1efd3f15bc7ab7083b1aaecfc00c64fd7..afe5f7dab0b625876da33174e3d9d84569b14e7b 100644 (file)
@@ -2155,6 +2155,10 @@ def Test_expr7_dict()
       # 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)
  
index bcf8b6d2b47634f960f161d2ce17483a6d5882ee..6ec87e4ba637fb06ea28df79ef04695ae68555a4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2629,
 /**/
     2628,
 /**/
index 9366e7632a8c029d3eff4b060c793d0bb635e478..8806de3137a7a48b3b34f50779d4ad56e02b914b 100644 (file)
@@ -120,7 +120,7 @@ not_in_vim9(exarg_T *eap)
     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;
@@ -129,13 +129,13 @@ vim9_bad_comment(char_u *p)
 }
 
 /*
- * 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)