Bram Moolenaar | 683fa18 | 2015-11-30 21:38:24 +0100 | [diff] [blame] | 1 | " Tests for 'undolevels' |
| 2 | |
Bram Moolenaar | 683fa18 | 2015-11-30 21:38:24 +0100 | [diff] [blame] | 3 | func 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 |
| 9 | endfunc |
| 10 | |
| 11 | func 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 Moolenaar | 4d58502 | 2016-04-14 19:50:22 +0200 | [diff] [blame] | 44 | " Drop created windows |
| 45 | set ul& |
| 46 | new |
| 47 | only! |
Bram Moolenaar | 683fa18 | 2015-11-30 21:38:24 +0100 | [diff] [blame] | 48 | endfunc |