Skip to content

Commit 36113e4

Browse files
committed
patch 8.2.1943: Vim9: wrong error message when colon is missing
Problem: Vim9: wrong error message when colon is missing. Solution: Check for a missing colon. (issue #7239)
1 parent dbfa795 commit 36113e4

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/ex_docmd.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,12 +1807,19 @@ do_one_cmd(
18071807
if (ea.cmd == cmd + 1 && *cmd == '$')
18081808
// should be "$VAR = val"
18091809
--ea.cmd;
1810-
else if (ea.cmd > cmd)
1810+
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
1811+
if (ea.cmdidx == CMD_SIZE)
18111812
{
1812-
emsg(_(e_colon_required_before_a_range));
1813-
goto doend;
1813+
char_u *ar = skip_range(ea.cmd, TRUE, NULL);
1814+
1815+
// If a ':' before the range is missing, give a clearer error
1816+
// message.
1817+
if (ar > ea.cmd)
1818+
{
1819+
emsg(_(e_colon_required_before_a_range));
1820+
goto doend;
1821+
}
18141822
}
1815-
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
18161823
}
18171824
else
18181825
#endif

src/testdir/test_vim9_cmd.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,15 @@ def Test_command_modifier_other()
460460
# verbose
461461
enddef
462462

463+
def Test_range_after_command_modifier()
464+
CheckScriptFailure(['vim9script', 'silent keepjump 1d _'], 'E1050:', 2)
465+
new
466+
setline(1, 'xxx')
467+
CheckScriptSuccess(['vim9script', 'silent keepjump :1d _'])
468+
assert_equal('', getline(1))
469+
bwipe!
470+
enddef
471+
463472
def Test_eval_command()
464473
var from = 3
465474
var to = 5

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1943,
753755
/**/
754756
1942,
755757
/**/

0 commit comments

Comments
 (0)