To: vim_dev@googlegroups.com Subject: Patch 8.2.3365 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3365 Problem: Vim9: cannot use option for all operations. Solution: Recognize more operations. (closes #8779) Files: src/vim9compile.c, src/proto/vim9compile.pro, src/ex_docmd.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.3364/src/vim9compile.c 2021-08-21 17:26:47.339002567 +0200 --- src/vim9compile.c 2021-08-21 19:35:58.934723374 +0200 *************** *** 3579,3585 **** * Return a pointer to just after the name. Equal to "arg" if there is no * valid name. */ ! static char_u * to_name_end(char_u *arg, int use_namespace) { char_u *p; --- 3579,3585 ---- * Return a pointer to just after the name. Equal to "arg" if there is no * valid name. */ ! char_u * to_name_end(char_u *arg, int use_namespace) { char_u *p; *** ../vim-8.2.3364/src/proto/vim9compile.pro 2021-08-09 19:59:01.442811242 +0200 --- src/proto/vim9compile.pro 2021-08-21 19:37:22.510588290 +0200 *************** *** 8,13 **** --- 8,14 ---- imported_T *find_imported_in_script(char_u *name, size_t len, int sid); char_u *peek_next_line_from_context(cctx_T *cctx); char_u *next_line_from_context(cctx_T *cctx, int skip_comment); + char_u *to_name_end(char_u *arg, int use_namespace); char_u *to_name_const_end(char_u *arg); int get_lambda_tv_and_compile(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg); exprtype_T get_compare_type(char_u *p, int *len, int *type_is); *** ../vim-8.2.3364/src/ex_docmd.c 2021-08-15 13:49:38.126905573 +0200 --- src/ex_docmd.c 2021-08-21 20:33:59.264236587 +0200 *************** *** 3425,3436 **** { char_u *pskip = skip_option_env_lead(eap->cmd); ! if (vim_strchr((char_u *)"{('[\"@", *p) != NULL || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) { int oplen; int heredoc; ! char_u *swp = skipwhite(p); if ( // "(..." is an expression. --- 3425,3450 ---- { char_u *pskip = skip_option_env_lead(eap->cmd); ! if (vim_strchr((char_u *)"{('[\"@&", *p) != NULL || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) { int oplen; int heredoc; ! char_u *swp; ! ! if (*eap->cmd == '&') ! { ! p = to_name_end(eap->cmd + 1, FALSE); ! if (ends_excmd(*skipwhite(p))) ! { ! // "&option " is the start of an expression. ! eap->cmdidx = CMD_eval; ! return eap->cmd; ! } ! // "&option" can be followed by "->" or "=", check below ! } ! ! swp = skipwhite(p); if ( // "(..." is an expression. *************** *** 3530,3539 **** --- 3544,3557 ---- // Recognize an assignment if we recognize the variable name: // "g:var = expr" + // "@r = expr" + // "&opt = expr" // "var = expr" where "var" is a variable name or we are skipping // (variable declaration might have been skipped). if (*eap->cmd == '@') p = eap->cmd + 2; + else if (*eap->cmd == '&') + p = skiptowhite_esc(eap->cmd + 1); oplen = assignment_len(skipwhite(p), &heredoc); if (oplen > 0) { *** ../vim-8.2.3364/src/testdir/test_vim9_cmd.vim 2021-08-15 13:49:38.126905573 +0200 --- src/testdir/test_vim9_cmd.vim 2021-08-21 20:41:58.983316196 +0200 *************** *** 521,526 **** --- 521,542 ---- CheckScriptSuccess(lines) enddef + def Test_option_use_linebreak() + var lines =<< trim END + new + &matchpairs = '(:)' + &matchpairs->setline(1) + &matchpairs = '[:]' + &matchpairs ->setline(2) + &matchpairs = '{:}' + &matchpairs + ->setline(3) + assert_equal(['(:)', '[:]', '{:}'], getline(1, '$')) + bwipe! + END + CheckDefAndScriptSuccess(lines) + enddef + def Test_skipped_expr_linebreak() if 0 var x = [] *** ../vim-8.2.3364/src/version.c 2021-08-21 17:26:47.339002567 +0200 --- src/version.c 2021-08-21 20:01:11.175935817 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3365, /**/ -- Living on Earth includes an annual free trip around the Sun. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///