]> granicus.if.org Git - vim/commitdiff
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior v8.2.2519
authorBram Moolenaar <Bram@vim.org>
Mon, 15 Feb 2021 20:30:30 +0000 (21:30 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 15 Feb 2021 20:30:30 +0000 (21:30 +0100)
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)

src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c

index 0dd21eb010129faadb9513d75ebbed5f5b2fc676..f4bdf7b152b2c5c8b9bf0139301b811a6c9df13b 100644 (file)
@@ -1957,12 +1957,16 @@ do_one_cmd(
        /*
         * strange vi behaviour:
         * ":3"         jumps to line 3
-        * ":3|..."     prints line 3
-        * ":|"         prints current line
+        * ":3|..."     prints line 3  (not in Vim9 script)
+        * ":|"         prints current line  (not in Vim9 script)
         */
        if (ea.skip)        // skip this if inside :if
            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.argt = EX_RANGE+EX_COUNT+EX_TRLBAR;
index 0becc7d1ba838890f1b6ec07cc27d6080942f64b..922080d9cf564509c7f4e57360bb8e4baf80a5ed 100644 (file)
@@ -22,6 +22,17 @@ def Test_range_only()
   :3
   list
   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!
 
   # won't generate anything
index 774ff529e061f74819ad049bc31c621b48dc40d5..02abac975277bf5117c1e7bf2ae68c597749f2cd 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2519,
 /**/
     2518,
 /**/