annotate src/testdir/test_changelist.vim @ 35172:c98f002b1fe4 default tip

runtime(doc): fix typo in usr_52.txt Commit: https://github.com/vim/vim/commit/b7258738f80f26be302a84a99f968b3bdc2f29bb Author: Christian Brabandt <cb@256bit.org> Date: Sun May 12 19:04:47 2024 +0200 runtime(doc): fix typo in usr_52.txt fixes: https://github.com/vim/vim/issues/14758 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 12 May 2024 19:15:08 +0200
parents f7a2de8a4ddc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the changelist functionality
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
29026
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
3 " When splitting a window the changelist position is wrong.
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4 " Test the changelist position after splitting a window.
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
5 " Test for the bug fixed by 7.4.386
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
6 func Test_changelist()
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
7 let save_ul = &ul
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
8 enew!
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
9 call append('$', ['1', '2'])
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
10 exe "normal i\<C-G>u"
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
11 exe "normal Gkylpa\<C-G>u"
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
12 set ul=100
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
13 exe "normal Gylpa\<C-G>u"
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
14 set ul=100
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
15 normal gg
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
16 vsplit
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
17 normal g;
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
18 call assert_equal([3, 2], [line('.'), col('.')])
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
19 normal g;
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
20 call assert_equal([2, 2], [line('.'), col('.')])
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
21 call assert_fails('normal g;', 'E662:')
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
22 new
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
23 call assert_fails('normal g;', 'E664:')
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
24 %bwipe!
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
25 let &ul = save_ul
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
26 endfunc
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
27
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
28 " Moving a split should not change its changelist index.
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
29 func Test_changelist_index_move_split()
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
30 exe "norm! iabc\<C-G>u\ndef\<C-G>u\nghi"
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
31 vsplit
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
32 normal 99g;
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
33 call assert_equal(0, getchangelist('%')[1])
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
34 wincmd L
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
35 call assert_equal(0, getchangelist('%')[1])
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
36 endfunc
5baf5e50049b patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
37
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 " Tests for the getchangelist() function
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
39 func Test_changelist_index()
29997
98f5a0618a77 patch 9.0.0336: tests are flaky because of using a common file name
Bram Moolenaar <Bram@vim.org>
parents: 29026
diff changeset
40 edit Xgclfile1.txt
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
41 exe "normal iabc\<C-G>u\ndef\<C-G>u\nghi"
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
42 call assert_equal(3, getchangelist('%')[1])
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
43 " Move one step back in the changelist.
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
44 normal 2g;
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
45
29997
98f5a0618a77 patch 9.0.0336: tests are flaky because of using a common file name
Bram Moolenaar <Bram@vim.org>
parents: 29026
diff changeset
46 hide edit Xgclfile2.txt
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
47 exe "normal iabcd\<C-G>u\ndefg\<C-G>u\nghij"
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
48 call assert_equal(3, getchangelist('%')[1])
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
49 " Move to the beginning of the changelist.
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
50 normal 99g;
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
51
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
52 " Check the changelist indices.
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
53 call assert_equal(0, getchangelist('%')[1])
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
54 call assert_equal(1, getchangelist('#')[1])
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
55
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
56 bwipe!
29997
98f5a0618a77 patch 9.0.0336: tests are flaky because of using a common file name
Bram Moolenaar <Bram@vim.org>
parents: 29026
diff changeset
57 call delete('Xgclfile1.txt')
98f5a0618a77 patch 9.0.0336: tests are flaky because of using a common file name
Bram Moolenaar <Bram@vim.org>
parents: 29026
diff changeset
58 call delete('Xgclfile2.txt')
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
59 endfunc
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
60
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 func Test_getchangelist()
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 bwipe!
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 enew
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 13290
diff changeset
64 call assert_equal([], 10->getchangelist())
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 13290
diff changeset
65 call assert_equal([[], 0], getchangelist())
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29997
diff changeset
67 call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt', 'D')
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29997
diff changeset
68 call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt', 'D')
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69
29997
98f5a0618a77 patch 9.0.0336: tests are flaky because of using a common file name
Bram Moolenaar <Bram@vim.org>
parents: 29026
diff changeset
70 edit Xclistfile1.txt
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
71 let buf_1 = bufnr()
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 exe "normal 1Goline\<C-G>u1.1"
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 exe "normal 3Goline\<C-G>u2.1"
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 exe "normal 5Goline\<C-G>u3.1"
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 normal g;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call assert_equal([[
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
13290
3f3d9ed211b2 patch 8.0.1519: getchangelist() does not use argument as bufname()
Christian Brabandt <cb@256bit.org>
parents: 13280
diff changeset
80 \ getchangelist('%'))
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81
29997
98f5a0618a77 patch 9.0.0336: tests are flaky because of using a common file name
Bram Moolenaar <Bram@vim.org>
parents: 29026
diff changeset
82 hide edit Xclistfile2.txt
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
83 let buf_2 = bufnr()
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 exe "normal 1GOline\<C-G>u1.0"
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 exe "normal 2Goline\<C-G>u2.0"
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 call assert_equal([[
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2],
13290
3f3d9ed211b2 patch 8.0.1519: getchangelist() does not use argument as bufname()
Christian Brabandt <cb@256bit.org>
parents: 13280
diff changeset
89 \ getchangelist('%'))
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 hide enew
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 call assert_equal([[
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
95 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
96 \ getchangelist(buf_1))
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 call assert_equal([[
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
99 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2],
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
100 \ getchangelist(buf_2))
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 bwipe!
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 endfunc
19625
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
104
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
105 " vim: shiftwidth=2 sts=2 expandtab