diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-23 19:34:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-23 19:34:48 +0200 |
commit | 2e80095501238e0c6b702ac7cdfa2e2b763dba28 (patch) | |
tree | b4768ed6a42285874dff041b2e18d1e22d9bbd98 /src/ex_docmd.c | |
parent | 6c53fca02301ff871cddc1c74c388e23e53a424a (diff) |
patch 8.2.1518: Vim9: cannot assign to local optionv8.2.1518
Problem: Vim9: cannot assign to local option.
Solution: Skip over "&l:" and "&g:". (closes #6749)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 854ff4dfb0..e252b05794 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3243,6 +3243,27 @@ append_command(char_u *cmd) } /* + * If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to + * the name. Otherwise just return "start". + */ + char_u * +skip_option_env_lead(char_u *start) +{ + char_u *name = start; + + if (*start == '&') + { + if ((start[1] == 'l' || start[1] == 'g') && start[2] == ':') + name += 3; + else + name += 1; + } + else if (*start == '$') + name += 1; + return name; +} + +/* * Find an Ex command by its name, either built-in or user. * Start of the name can be found at eap->cmd. * Sets eap->cmdidx and returns a pointer to char after the command name. @@ -3273,9 +3294,7 @@ find_ex_command( p = eap->cmd; if (lookup != NULL) { - // Skip over first char for "&opt = val", "$ENV = val" and "@r = val". - char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$') - ? eap->cmd + 1 : eap->cmd; + 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)) |