]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1954: Vim9: not all command modifiers are tested v8.2.1954
authorBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 17:02:44 +0000 (18:02 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 17:02:44 +0000 (18:02 +0100)
Problem:    Vim9: not all command modifiers are tested.
Solution:   Add tests for "keep" modifiers.  Fix that marks are lost even
            though ":lockmarks" is used.

src/ex_cmds.c
src/testdir/test_vim9_cmd.vim
src/version.c

index de4b806b27717c8c3e99e48b5648be4421039f33..185033f1d5520e603b704c4cebd6aaa26271663b 100644 (file)
@@ -1254,6 +1254,16 @@ do_filter(
                if (read_linecount >= linecount)
                    // move all marks from old lines to new lines
                    mark_adjust(line1, line2, linecount, 0L);
+               else if (save_cmod_flags & CMOD_LOCKMARKS)
+               {
+                   // Move marks from the lines below the new lines down by
+                   // the number of lines lost.
+                   // Move marks from the lines that will be deleted to the
+                   // new lines and below.
+                   mark_adjust(line2 + 1, (linenr_T)MAXLNUM,
+                                              linecount - read_linecount, 0L);
+                   mark_adjust(line1, line2, linecount, 0L);
+               }
                else
                {
                    // move marks from old lines to new lines, delete marks
index 2ba779b7669b6ac113a909d7c7e2647a51d22070..71c47cdcefa8b815919fa5f2f5aa7e54607c3502 100644 (file)
@@ -439,13 +439,42 @@ def Test_command_modifiers_keep()
     DoTest(false, true, true)
     DoTest(true, true, true)
     set cpo&vim
+
+    new
+    setline(1, ['one', 'two', 'three', 'four'])
+    assert_equal(4, line("$"))
+    normal 1Gma
+    normal 2Gmb
+    normal 3Gmc
+    lockmarks :1,2!wc
+    # line is deleted, marks don't move
+    assert_equal(3, line("$"))
+    assert_equal('four', getline(3))
+    assert_equal(1, line("'a"))
+    assert_equal(2, line("'b"))
+    assert_equal(3, line("'c"))
+    quit!
   endif
 
-  # TODO
-  # lockmarks
-  # keepalt
-  # keeppatterns
-  # keepjumps
+  edit Xone
+  edit Xtwo
+  assert_equal('Xone', expand('#'))
+  keepalt edit Xthree
+  assert_equal('Xone', expand('#'))
+
+  normal /a*b*
+  assert_equal('a*b*', histget("search"))
+  keeppatterns normal /c*d*
+  assert_equal('a*b*', histget("search"))
+
+  new
+  setline(1, range(10))
+  :10
+  normal gg
+  assert_equal(10, getpos("''")[1])
+  keepjumps normal 5G
+  assert_equal(10, getpos("''")[1])
+  quit!
 enddef
 
 def Test_command_modifier_other()
index a55d2f3eeef32199bde3d46b0ada5f6170bcc0cc..231a4f0388030c46792b64ba4a165baff7c13c00 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1954,
 /**/
     1953,
 /**/