Skip to content

Commit 7317091

Browse files
committed
patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Problem: Vim9: :@r executing a register is inconsistent. Solution: Use "@r" as the start of an expression. (issue #8779)
1 parent 093165c commit 7317091

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

src/ex_docmd.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,12 +3432,23 @@ find_ex_command(
34323432
int heredoc;
34333433
char_u *swp;
34343434

3435-
if (*eap->cmd == '&')
3435+
if (*eap->cmd == '&' || (eap->cmd[0] == '@'
3436+
&& (valid_yank_reg(eap->cmd[1], FALSE)
3437+
|| eap->cmd[1] == '@')))
34363438
{
3437-
p = to_name_end(eap->cmd + 1, FALSE);
3439+
if (*eap->cmd == '&')
3440+
{
3441+
p = eap->cmd + 1;
3442+
if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
3443+
p += 2;
3444+
p = to_name_end(p, FALSE);
3445+
}
3446+
else
3447+
p = eap->cmd + 2;
34383448
if (ends_excmd(*skipwhite(p)))
34393449
{
3440-
// "&option <NL>" is the start of an expression.
3450+
// "&option <NL>" and "@r <NL>" is the start of an
3451+
// expression.
34413452
eap->cmdidx = CMD_eval;
34423453
return eap->cmd;
34433454
}
@@ -3548,10 +3559,6 @@ find_ex_command(
35483559
// "&opt = expr"
35493560
// "var = expr" where "var" is a variable name or we are skipping
35503561
// (variable declaration might have been skipped).
3551-
if (*eap->cmd == '@')
3552-
p = eap->cmd + 2;
3553-
else if (*eap->cmd == '&')
3554-
p = skiptowhite_esc(eap->cmd + 1);
35553562
oplen = assignment_len(skipwhite(p), &heredoc);
35563563
if (oplen > 0)
35573564
{

src/testdir/test_vim9_cmd.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,22 @@ def Test_option_use_linebreak()
537537
CheckDefAndScriptSuccess(lines)
538538
enddef
539539

540+
def Test_register_use_linebreak()
541+
var lines =<< trim END
542+
new
543+
@a = 'one'
544+
@a->setline(1)
545+
@b = 'two'
546+
@b ->setline(2)
547+
@c = 'three'
548+
@c
549+
->setline(3)
550+
assert_equal(['one', 'two', 'three'], getline(1, '$'))
551+
bwipe!
552+
END
553+
CheckDefAndScriptSuccess(lines)
554+
enddef
555+
540556
def Test_skipped_expr_linebreak()
541557
if 0
542558
var x = []

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3367,
758760
/**/
759761
3366,
760762
/**/

0 commit comments

Comments
 (0)