Skip to content

Commit b855430

Browse files
committed
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Problem: Vim9: no reason to keep strange Vi behavior. Solution: ":3" and ":3|" both go to line 3. ":|" does not print the line. (closes #7840)
1 parent eed9d46 commit b855430

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/ex_docmd.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,12 +1957,16 @@ do_one_cmd(
19571957
/*
19581958
* strange vi behaviour:
19591959
* ":3" jumps to line 3
1960-
* ":3|..." prints line 3
1961-
* ":|" prints current line
1960+
* ":3|..." prints line 3 (not in Vim9 script)
1961+
* ":|" prints current line (not in Vim9 script)
19621962
*/
19631963
if (ea.skip) // skip this if inside :if
19641964
goto doend;
1965-
if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2))
1965+
if ((*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2))
1966+
#ifdef FEAT_EVAL
1967+
&& !vim9script
1968+
#endif
1969+
)
19661970
{
19671971
ea.cmdidx = CMD_print;
19681972
ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR;

src/testdir/test_vim9_script.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ def Test_range_only()
2222
:3
2323
list
2424
assert_equal('three$', Screenline(&lines))
25+
26+
# missing command does not print the line
27+
var lines =<< trim END
28+
vim9script
29+
:1|
30+
assert_equal('three$', Screenline(&lines))
31+
:|
32+
assert_equal('three$', Screenline(&lines))
33+
END
34+
CheckScriptSuccess(lines)
35+
2536
bwipe!
2637

2738
# won't generate anything

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+
2519,
753755
/**/
754756
2518,
755757
/**/

0 commit comments

Comments
 (0)