To: vim_dev@googlegroups.com Subject: Patch 8.2.2629 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2629 Problem: Vim9: error for #{{ is not desired. Solution: Adjust the checks. (closes #7990) Files: src/errors.h, src/vim9script.c, src/ex_docmd.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.2628/src/errors.h 2021-03-18 21:37:52.196105245 +0100 --- src/errors.h 2021-03-20 14:46:48.671016498 +0100 *************** *** 376,379 **** 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")); --- 376,379 ---- 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")); *** ../vim-8.2.2628/src/vim9script.c 2021-03-18 22:15:00.585208312 +0100 --- src/vim9script.c 2021-03-20 14:51:06.298079001 +0100 *************** *** 120,126 **** int vim9_bad_comment(char_u *p) { ! if (p[0] == '#' && p[1] == '{') { emsg(_(e_cannot_use_hash_curly_to_start_comment)); return TRUE; --- 120,126 ---- int vim9_bad_comment(char_u *p) { ! if (p[0] == '#' && p[1] == '{' && p[2] != '{') { emsg(_(e_cannot_use_hash_curly_to_start_comment)); return TRUE; *************** *** 129,141 **** } /* ! * Return TRUE if "p" points at a "#" not followed by '{'. * Does not check for white space. */ int vim9_comment_start(char_u *p) { ! return p[0] == '#' && p[1] != '{'; } #if defined(FEAT_EVAL) || defined(PROTO) --- 129,141 ---- } /* ! * 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] != '{' || p[2] == '{'); } #if defined(FEAT_EVAL) || defined(PROTO) *** ../vim-8.2.2628/src/ex_docmd.c 2021-03-20 13:29:35.255669769 +0100 --- src/ex_docmd.c 2021-03-20 14:57:41.172821562 +0100 *************** *** 5234,5240 **** return TRUE; #ifdef FEAT_EVAL if (in_vim9script()) ! return c == '#' && cmd[1] != '{' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1])); #endif return c == '"'; --- 5234,5241 ---- return TRUE; #ifdef FEAT_EVAL if (in_vim9script()) ! // # 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 == '"'; *** ../vim-8.2.2628/src/testdir/test_vim9_expr.vim 2021-03-20 13:29:35.255669769 +0100 --- src/testdir/test_vim9_expr.vim 2021-03-20 14:54:06.341485943 +0100 *************** *** 2155,2160 **** --- 2155,2164 ---- # 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) *** ../vim-8.2.2628/src/version.c 2021-03-20 13:29:35.259669790 +0100 --- src/version.c 2021-03-20 14:51:56.417909685 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2629, /**/ -- hundred-and-one symptoms of being an internet addict: 1. You actually wore a blue ribbon to protest the Communications Decency Act. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///