summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-22 15:05:46 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-22 15:05:46 +0000
commit7d5b8becc342e49e491053ea842e59f82d072001 (patch)
tree0109a6c312198036b7a042a89656426027efddf3
parent2228cd72cf7c6f326e4e41179e88d37595ca4abc (diff)
downloadvim-git-8.2.3645.tar.gz
patch 8.2.3645: Vim9: The "no effect" error is not given for all registersv8.2.3645
Problem: Vim9: The "no effect" error is not given for all registers. Solution: Include any character following '@'. (closes #8779)
-rw-r--r--src/ex_eval.c24
-rw-r--r--src/testdir/test_vim9_cmd.vim29
-rw-r--r--src/version.c2
3 files changed, 47 insertions, 8 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c
index 1f66e336f..d80500eb0 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -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;
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 0fa65d1b2..31f20cb26 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -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()
diff --git a/src/version.c b/src/version.c
index 67b263452..d91f522a2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3645,
+/**/
3644,
/**/
3643,