Skip to content

Commit f65b35b

Browse files
committed
patch 8.2.1954: Vim9: not all command modifiers are tested
Problem: Vim9: not all command modifiers are tested. Solution: Add tests for "keep" modifiers. Fix that marks are lost even though ":lockmarks" is used.
1 parent 631e8f9 commit f65b35b

3 files changed

Lines changed: 46 additions & 5 deletions

File tree

src/ex_cmds.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,16 @@ do_filter(
12541254
if (read_linecount >= linecount)
12551255
// move all marks from old lines to new lines
12561256
mark_adjust(line1, line2, linecount, 0L);
1257+
else if (save_cmod_flags & CMOD_LOCKMARKS)
1258+
{
1259+
// Move marks from the lines below the new lines down by
1260+
// the number of lines lost.
1261+
// Move marks from the lines that will be deleted to the
1262+
// new lines and below.
1263+
mark_adjust(line2 + 1, (linenr_T)MAXLNUM,
1264+
linecount - read_linecount, 0L);
1265+
mark_adjust(line1, line2, linecount, 0L);
1266+
}
12571267
else
12581268
{
12591269
// move marks from old lines to new lines, delete marks

src/testdir/test_vim9_cmd.vim

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,42 @@ def Test_command_modifiers_keep()
439439
DoTest(false, true, true)
440440
DoTest(true, true, true)
441441
set cpo&vim
442+
443+
new
444+
setline(1, ['one', 'two', 'three', 'four'])
445+
assert_equal(4, line("$"))
446+
normal 1Gma
447+
normal 2Gmb
448+
normal 3Gmc
449+
lockmarks :1,2!wc
450+
# line is deleted, marks don't move
451+
assert_equal(3, line("$"))
452+
assert_equal('four', getline(3))
453+
assert_equal(1, line("'a"))
454+
assert_equal(2, line("'b"))
455+
assert_equal(3, line("'c"))
456+
quit!
442457
endif
443458

444-
# TODO
445-
# lockmarks
446-
# keepalt
447-
# keeppatterns
448-
# keepjumps
459+
edit Xone
460+
edit Xtwo
461+
assert_equal('Xone', expand('#'))
462+
keepalt edit Xthree
463+
assert_equal('Xone', expand('#'))
464+
465+
normal /a*b*
466+
assert_equal('a*b*', histget("search"))
467+
keeppatterns normal /c*d*
468+
assert_equal('a*b*', histget("search"))
469+
470+
new
471+
setline(1, range(10))
472+
:10
473+
normal gg
474+
assert_equal(10, getpos("''")[1])
475+
keepjumps normal 5G
476+
assert_equal(10, getpos("''")[1])
477+
quit!
449478
enddef
450479

451480
def Test_command_modifier_other()

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+
1954,
753755
/**/
754756
1953,
755757
/**/

0 commit comments

Comments
 (0)