Mercurial > vim
diff src/ex_docmd.c @ 21937:b931df03adcc v8.2.1518
patch 8.2.1518: Vim9: cannot assign to local option
Commit: https://github.com/vim/vim/commit/2e80095501238e0c6b702ac7cdfa2e2b763dba28
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 23 19:34:48 2020 +0200
patch 8.2.1518: Vim9: cannot assign to local option
Problem: Vim9: cannot assign to local option.
Solution: Skip over "&l:" and "&g:". (closes https://github.com/vim/vim/issues/6749)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 23 Aug 2020 19:45:03 +0200 |
parents | f19ac9b8b011 |
children | 8350bdbdbb28 |
line wrap: on
line diff
--- 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))