annotate src/testdir/test_marks.vim @ 10730:44e9340dc604 v8.0.0255

patch 8.0.0255: setpos() does not use the buffer argument for all marks commit https://github.com/vim/vim/commit/f13e00b2cf381e13fd327b5387a5bd6f004ac2a3 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 28 18:23:54 2017 +0100 patch 8.0.0255: setpos() does not use the buffer argument for all marks Problem: When calling setpos() with a buffer argument it often is ignored. (Matthew Malcomson) Solution: Make the buffer argument work for all marks local to a buffer. (neovim #5713) Add more tests.
author Christian Brabandt <cb@256bit.org>
date Sat, 28 Jan 2017 18:30:04 +0100
parents c577c6a2e88b
children 3b600d16d9cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Test that a deleted mark is restored after delete-undo-redo-undo.
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 function! Test_Restore_DelMark()
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 enew!
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 call append(0, [" textline A", " textline B", " textline C"])
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 normal! 2gg
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 set nocp viminfo+=nviminfo
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 exe "normal! i\<C-G>u\<Esc>"
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 exe "normal! maddu\<C-R>u"
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let pos = getpos("'a")
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call assert_equal(2, pos[1])
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal(1, pos[2])
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 enew!
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 endfunction
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " Test that CTRL-A and CTRL-X updates last changed mark '[, '].
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 function! Test_Incr_Marks()
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 enew!
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call append(0, ["123 123 123", "123 123 123", "123 123 123"])
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 normal! gg
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 execute "normal! \<C-A>`[v`]rAjwvjw\<C-X>`[v`]rX"
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal("AAA 123 123", getline(1))
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal("123 XXXXXXX", getline(2))
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_equal("XXX 123 123", getline(3))
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 enew!
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 endfunction
10730
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
27
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
28 func Test_setpos()
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
29 new one
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
30 let onebuf = bufnr('%')
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
31 let onewin = win_getid()
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
32 call setline(1, ['aaa', 'bbb', 'ccc'])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
33 new two
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
34 let twobuf = bufnr('%')
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
35 let twowin = win_getid()
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
36 call setline(1, ['aaa', 'bbb', 'ccc'])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
37
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
38 " for the cursor the buffer number is ignored
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
39 call setpos(".", [0, 2, 1, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
40 call assert_equal([0, 2, 1, 0], getpos("."))
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
41 call setpos(".", [onebuf, 3, 3, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
42 call assert_equal([0, 3, 3, 0], getpos("."))
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
43
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
44 call setpos("''", [0, 1, 3, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
45 call assert_equal([0, 1, 3, 0], getpos("''"))
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
46 call setpos("''", [onebuf, 2, 2, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
47 call assert_equal([0, 2, 2, 0], getpos("''"))
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
48
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
49 " buffer-local marks
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
50 for mark in ["'a", "'\"", "'[", "']", "'<", "'>"]
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
51 call win_gotoid(twowin)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
52 call setpos(mark, [0, 2, 1, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
53 call assert_equal([0, 2, 1, 0], getpos(mark), "for mark " . mark)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
54 call setpos(mark, [onebuf, 1, 3, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
55 call win_gotoid(onewin)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
56 call assert_equal([0, 1, 3, 0], getpos(mark), "for mark " . mark)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
57 endfor
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
58
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
59 " global marks
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
60 call win_gotoid(twowin)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
61 call setpos("'N", [0, 2, 1, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
62 call assert_equal([twobuf, 2, 1, 0], getpos("'N"))
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
63 call setpos("'N", [onebuf, 1, 3, 0])
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
64 call assert_equal([onebuf, 1, 3, 0], getpos("'N"))
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
65
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
66 call win_gotoid(onewin)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
67 bwipe!
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
68 call win_gotoid(twowin)
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
69 bwipe!
44e9340dc604 patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
70 endfunc