xref: /vim-8.2.3635/src/testdir/test_marks.vim (revision e0720cbf)
1
2" Test that a deleted mark is restored after delete-undo-redo-undo.
3function! Test_Restore_DelMark()
4  enew!
5  call append(0, ["	textline A", "	textline B", "	textline C"])
6  normal! 2gg
7  set nocp viminfo+=nviminfo
8  exe "normal! i\<C-G>u\<Esc>"
9  exe "normal! maddu\<C-R>u"
10  let pos = getpos("'a")
11  call assert_equal(2, pos[1])
12  call assert_equal(1, pos[2])
13  enew!
14endfunction
15
16" Test that CTRL-A and CTRL-X updates last changed mark '[, '].
17function! Test_Incr_Marks()
18  enew!
19  call append(0, ["123 123 123", "123 123 123", "123 123 123"])
20  normal! gg
21  execute "normal! \<C-A>`[v`]rAjwvjw\<C-X>`[v`]rX"
22  call assert_equal("AAA 123 123", getline(1))
23  call assert_equal("123 XXXXXXX", getline(2))
24  call assert_equal("XXX 123 123", getline(3))
25  enew!
26endfunction
27
28func Test_setpos()
29  new one
30  let onebuf = bufnr('%')
31  let onewin = win_getid()
32  call setline(1, ['aaa', 'bbb', 'ccc'])
33  new two
34  let twobuf = bufnr('%')
35  let twowin = win_getid()
36  call setline(1, ['aaa', 'bbb', 'ccc'])
37
38  " for the cursor the buffer number is ignored
39  call setpos(".", [0, 2, 1, 0])
40  call assert_equal([0, 2, 1, 0], getpos("."))
41  call setpos(".", [onebuf, 3, 3, 0])
42  call assert_equal([0, 3, 3, 0], getpos("."))
43
44  call setpos("''", [0, 1, 3, 0])
45  call assert_equal([0, 1, 3, 0], getpos("''"))
46  call setpos("''", [onebuf, 2, 2, 0])
47  call assert_equal([0, 2, 2, 0], getpos("''"))
48
49  " buffer-local marks
50  for mark in ["'a", "'\"", "'[", "']", "'<", "'>"]
51    call win_gotoid(twowin)
52    call setpos(mark, [0, 2, 1, 0])
53    call assert_equal([0, 2, 1, 0], getpos(mark), "for mark " . mark)
54    call setpos(mark, [onebuf, 1, 3, 0])
55    call win_gotoid(onewin)
56    call assert_equal([0, 1, 3, 0], getpos(mark), "for mark " . mark)
57  endfor
58
59  " global marks
60  call win_gotoid(twowin)
61  call setpos("'N", [0, 2, 1, 0])
62  call assert_equal([twobuf, 2, 1, 0], getpos("'N"))
63  call setpos("'N", [onebuf, 1, 3, 0])
64  call assert_equal([onebuf, 1, 3, 0], getpos("'N"))
65
66  call win_gotoid(onewin)
67  bwipe!
68  call win_gotoid(twowin)
69  bwipe!
70endfunc
71