0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1518: Vim9: cannot assign to local option

Problem:    Vim9: cannot assign to local option.
Solution:   Skip over "&l:" and "&g:". (closes #6749)
This commit is contained in:
Bram Moolenaar
2020-08-23 19:34:48 +02:00
parent 6c53fca023
commit 2e80095501
6 changed files with 51 additions and 18 deletions

View File

@@ -3242,6 +3242,27 @@ append_command(char_u *cmd)
*d = NUL;
}
/*
* 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.
@@ -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))