Bram Moolenaar | 683fa18 | 2015-11-30 21:38:24 +0100 | [diff] [blame] | 1 | " Tests for 'undolevels' |
| 2 | |
| 3 | set nocompatible viminfo+=nviminfo |
| 4 | |
| 5 | func FillBuffer() |
| 6 | for i in range(1,13) |
| 7 | put=i |
| 8 | " Set 'undolevels' to split undo. |
| 9 | exe "setg ul=" . &g:ul |
| 10 | endfor |
| 11 | endfunc |
| 12 | |
| 13 | func Test_global_local_undolevels() |
| 14 | new one |
| 15 | set undolevels=5 |
| 16 | call FillBuffer() |
| 17 | " will only undo the last 5 changes, end up with 13 - (5 + 1) = 7 lines |
| 18 | earlier 10 |
| 19 | call assert_equal(5, &g:undolevels) |
| 20 | call assert_equal(-123456, &l:undolevels) |
| 21 | call assert_equal('7', getline('$')) |
| 22 | |
| 23 | new two |
| 24 | setlocal undolevels=2 |
| 25 | call FillBuffer() |
| 26 | " will only undo the last 2 changes, end up with 13 - (2 + 1) = 10 lines |
| 27 | earlier 10 |
| 28 | call assert_equal(5, &g:undolevels) |
| 29 | call assert_equal(2, &l:undolevels) |
| 30 | call assert_equal('10', getline('$')) |
| 31 | |
| 32 | setlocal ul=10 |
| 33 | call assert_equal(5, &g:undolevels) |
| 34 | call assert_equal(10, &l:undolevels) |
| 35 | |
| 36 | " Setting local value in "two" must not change local value in "one" |
| 37 | wincmd p |
| 38 | call assert_equal(5, &g:undolevels) |
| 39 | call assert_equal(-123456, &l:undolevels) |
| 40 | |
| 41 | new three |
| 42 | setglobal ul=50 |
| 43 | call assert_equal(50, &g:undolevels) |
| 44 | call assert_equal(-123456, &l:undolevels) |
| 45 | |
| 46 | endfunc |