Mercurial > vim
comparison src/ex_docmd.c @ 25658:483b40e87ca5 v8.2.3365
patch 8.2.3365: Vim9: cannot use option for all operations
Commit: https://github.com/vim/vim/commit/bf5f2878333da934a8bdc560bf0bcf9a88ff86a1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 21 20:50:35 2021 +0200
patch 8.2.3365: Vim9: cannot use option for all operations
Problem: Vim9: cannot use option for all operations.
Solution: Recognize more operations. (closes https://github.com/vim/vim/issues/8779)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 21 Aug 2021 21:00:03 +0200 |
parents | 15b54e0a576b |
children | 23f065f27d2e |
comparison
equal
deleted
inserted
replaced
25657:26c53bca9f23 | 25658:483b40e87ca5 |
---|---|
3423 p = eap->cmd; | 3423 p = eap->cmd; |
3424 if (lookup != NULL) | 3424 if (lookup != NULL) |
3425 { | 3425 { |
3426 char_u *pskip = skip_option_env_lead(eap->cmd); | 3426 char_u *pskip = skip_option_env_lead(eap->cmd); |
3427 | 3427 |
3428 if (vim_strchr((char_u *)"{('[\"@", *p) != NULL | 3428 if (vim_strchr((char_u *)"{('[\"@&", *p) != NULL |
3429 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) | 3429 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) |
3430 { | 3430 { |
3431 int oplen; | 3431 int oplen; |
3432 int heredoc; | 3432 int heredoc; |
3433 char_u *swp = skipwhite(p); | 3433 char_u *swp; |
3434 | |
3435 if (*eap->cmd == '&') | |
3436 { | |
3437 p = to_name_end(eap->cmd + 1, FALSE); | |
3438 if (ends_excmd(*skipwhite(p))) | |
3439 { | |
3440 // "&option <NL>" is the start of an expression. | |
3441 eap->cmdidx = CMD_eval; | |
3442 return eap->cmd; | |
3443 } | |
3444 // "&option" can be followed by "->" or "=", check below | |
3445 } | |
3446 | |
3447 swp = skipwhite(p); | |
3434 | 3448 |
3435 if ( | 3449 if ( |
3436 // "(..." is an expression. | 3450 // "(..." is an expression. |
3437 // "funcname(" is always a function call. | 3451 // "funcname(" is always a function call. |
3438 *p == '(' | 3452 *p == '(' |
3528 } | 3542 } |
3529 } | 3543 } |
3530 | 3544 |
3531 // Recognize an assignment if we recognize the variable name: | 3545 // Recognize an assignment if we recognize the variable name: |
3532 // "g:var = expr" | 3546 // "g:var = expr" |
3547 // "@r = expr" | |
3548 // "&opt = expr" | |
3533 // "var = expr" where "var" is a variable name or we are skipping | 3549 // "var = expr" where "var" is a variable name or we are skipping |
3534 // (variable declaration might have been skipped). | 3550 // (variable declaration might have been skipped). |
3535 if (*eap->cmd == '@') | 3551 if (*eap->cmd == '@') |
3536 p = eap->cmd + 2; | 3552 p = eap->cmd + 2; |
3553 else if (*eap->cmd == '&') | |
3554 p = skiptowhite_esc(eap->cmd + 1); | |
3537 oplen = assignment_len(skipwhite(p), &heredoc); | 3555 oplen = assignment_len(skipwhite(p), &heredoc); |
3538 if (oplen > 0) | 3556 if (oplen > 0) |
3539 { | 3557 { |
3540 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') | 3558 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') |
3541 || *eap->cmd == '&' | 3559 || *eap->cmd == '&' |