Skip to content

Commit 83f37b9

Browse files
committed
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Problem: Vim9: :substitute(pat(repl does not work in Vim9 script. Solution: Remember starting with a colon. (closes #5676)
1 parent 8040a71 commit 83f37b9

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/ex_docmd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,9 @@ do_one_cmd(
16471647
int save_reg_executing = reg_executing;
16481648
int ni; // set when Not Implemented
16491649
char_u *cmd;
1650+
#ifdef FEAT_EVAL
1651+
int starts_with_colon;
1652+
#endif
16501653

16511654
vim_memset(&ea, 0, sizeof(ea));
16521655
ea.line1 = 1;
@@ -1689,6 +1692,7 @@ do_one_cmd(
16891692
ea.cookie = cookie;
16901693
#ifdef FEAT_EVAL
16911694
ea.cstack = cstack;
1695+
starts_with_colon = *skipwhite(ea.cmd) == ':';
16921696
#endif
16931697
if (parse_command_modifiers(&ea, &errormsg, FALSE) == FAIL)
16941698
goto doend;
@@ -1713,7 +1717,7 @@ do_one_cmd(
17131717
ea.cmd = skipwhite(ea.cmd + 1);
17141718

17151719
#ifdef FEAT_EVAL
1716-
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
1720+
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon)
17171721
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
17181722
else
17191723
#endif

src/testdir/test_vim9_script.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,21 @@ def Test_substitute_cmd()
580580
setline(1, 'something')
581581
:substitute(some(other(
582582
assert_equal('otherthing', getline(1))
583+
bwipe!
584+
585+
" also when the context is Vim9 script
586+
let lines =<< trim END
587+
vim9script
588+
new
589+
setline(1, 'something')
590+
:substitute(some(other(
591+
assert_equal('otherthing', getline(1))
592+
bwipe!
593+
END
594+
writefile(lines, 'Xvim9lines')
595+
source Xvim9lines
596+
597+
delete('Xvim9lines')
583598
enddef
584599

585600

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
306,
741743
/**/
742744
305,
743745
/**/

0 commit comments

Comments
 (0)