blob: b96b6934b06e96c2de4f86de6a06bd6064c0f0e9 [file] [log] [blame]
Bram Moolenaar683fa182015-11-30 21:38:24 +01001" Tests for 'undolevels'
2
Bram Moolenaar683fa182015-11-30 21:38:24 +01003func FillBuffer()
4 for i in range(1,13)
5 put=i
6 " Set 'undolevels' to split undo.
7 exe "setg ul=" . &g:ul
8 endfor
9endfunc
10
11func Test_global_local_undolevels()
12 new one
13 set undolevels=5
14 call FillBuffer()
15 " will only undo the last 5 changes, end up with 13 - (5 + 1) = 7 lines
16 earlier 10
17 call assert_equal(5, &g:undolevels)
18 call assert_equal(-123456, &l:undolevels)
19 call assert_equal('7', getline('$'))
20
21 new two
22 setlocal undolevels=2
23 call FillBuffer()
24 " will only undo the last 2 changes, end up with 13 - (2 + 1) = 10 lines
25 earlier 10
26 call assert_equal(5, &g:undolevels)
27 call assert_equal(2, &l:undolevels)
28 call assert_equal('10', getline('$'))
29
30 setlocal ul=10
31 call assert_equal(5, &g:undolevels)
32 call assert_equal(10, &l:undolevels)
33
34 " Setting local value in "two" must not change local value in "one"
35 wincmd p
36 call assert_equal(5, &g:undolevels)
37 call assert_equal(-123456, &l:undolevels)
38
39 new three
40 setglobal ul=50
41 call assert_equal(50, &g:undolevels)
42 call assert_equal(-123456, &l:undolevels)
43
Bram Moolenaar4d585022016-04-14 19:50:22 +020044 " Drop created windows
45 set ul&
46 new
47 only!
Bram Moolenaar683fa182015-11-30 21:38:24 +010048endfunc