Skip to content

Commit

Permalink
patch 8.2.3645: Vim9: The "no effect" error is not given for all regi…
Browse files Browse the repository at this point in the history
…sters

Problem:    Vim9: The "no effect" error is not given for all registers.
Solution:   Include any character following '@'. (closes #8779)
  • Loading branch information
brammool committed Nov 22, 2021
1 parent 2228cd7 commit 7d5b8be
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/ex_eval.c
Expand Up @@ -887,22 +887,32 @@ report_discard_pending(int pending, void *value)
}
}

/*
* Return TRUE if "arg" is only a variable, register or option name.
*/
int
cmd_is_name_only(char_u *arg)
{
char_u *p = arg;
char_u *alias;
char_u *alias = NULL;
int name_only = FALSE;

if (*p == '&')
if (*p == '@')
{
++p;
if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
p += 2;
if (*p != NUL)
++p;
}
else
{
if (*p == '&')
{
++p;
if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
p += 2;
}
get_name_len(&p, &alias, FALSE, FALSE);
}
else if (*p == '@')
++p;
get_name_len(&p, &alias, FALSE, FALSE);
name_only = ends_excmd2(arg, skipwhite(p));
vim_free(alias);
return name_only;
Expand Down
29 changes: 28 additions & 1 deletion src/testdir/test_vim9_cmd.vim
Expand Up @@ -556,7 +556,34 @@ def Test_use_register()
@a = 'echo "text"'
@a
END
CheckDefAndScriptFailure(lines, 'E1207:')
CheckDefAndScriptFailure(lines, 'E1207:', 2)

lines =<< trim END
@/ = 'pattern'
@/
END
CheckDefAndScriptFailure(lines, 'E1207:', 2)

lines =<< trim END
&opfunc = 'nothing'
&opfunc
END
CheckDefAndScriptFailure(lines, 'E1207:', 2)
&opfunc = ''

lines =<< trim END
&l:showbreak = 'nothing'
&l:showbreak
END
CheckDefAndScriptFailure(lines, 'E1207:', 2)
&l:showbreak = ''

lines =<< trim END
&g:showbreak = 'nothing'
&g:showbreak
END
CheckDefAndScriptFailure(lines, 'E1207:', 2)
&g:showbreak = ''
enddef

def Test_environment_use_linebreak()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -757,6 +757,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3645,
/**/
3644,
/**/
Expand Down

0 comments on commit 7d5b8be

Please sign in to comment.