1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2021-02-15 21:30:30 +01:00
parent eed9d46293
commit b8554304c3
3 changed files with 20 additions and 3 deletions

View File

@@ -1957,12 +1957,16 @@ do_one_cmd(
/* /*
* strange vi behaviour: * strange vi behaviour:
* ":3" jumps to line 3 * ":3" jumps to line 3
* ":3|..." prints line 3 * ":3|..." prints line 3 (not in Vim9 script)
* ":|" prints current line * ":|" prints current line (not in Vim9 script)
*/ */
if (ea.skip) // skip this if inside :if if (ea.skip) // skip this if inside :if
goto doend; goto doend;
if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) if ((*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2))
#ifdef FEAT_EVAL
&& !vim9script
#endif
)
{ {
ea.cmdidx = CMD_print; ea.cmdidx = CMD_print;
ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR;

View File

@@ -22,6 +22,17 @@ def Test_range_only()
:3 :3
list list
assert_equal('three$', Screenline(&lines)) assert_equal('three$', Screenline(&lines))
# missing command does not print the line
var lines =<< trim END
vim9script
:1|
assert_equal('three$', Screenline(&lines))
:|
assert_equal('three$', Screenline(&lines))
END
CheckScriptSuccess(lines)
bwipe! bwipe!
# won't generate anything # won't generate anything

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2519,
/**/ /**/
2518, 2518,
/**/ /**/