comparison src/testdir/test_changelist.vim @ 13280:fbda23eb0996 v8.0.1514

patch 8.0.1514: getting the list of changes is not easy commit https://github.com/vim/vim/commit/07ad816525da67cab3c0db21d1286d221dbc7477 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 13 13:59:59 2018 +0100 patch 8.0.1514: getting the list of changes is not easy Problem: Getting the list of changes is not easy. Solution: Add the getchangelist() function. (Yegappan Lakshmanan, closes #2634)
author Christian Brabandt <cb@256bit.org>
date Tue, 13 Feb 2018 14:15:05 +0100
parents
children 3f3d9ed211b2
comparison
equal deleted inserted replaced
13279:fa46af018785 13280:fbda23eb0996
1 " Tests for the changelist functionality
2
3 " Tests for the getchangelist() function
4 func Test_getchangelist()
5 if !has("jumplist")
6 return
7 endif
8
9 bwipe!
10 enew
11 call assert_equal([], getchangelist(10))
12 call assert_equal([[], 0], getchangelist(bufnr('%')))
13
14 call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
15 call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')
16
17 edit Xfile1.txt
18 exe "normal 1Goline\<C-G>u1.1"
19 exe "normal 3Goline\<C-G>u2.1"
20 exe "normal 5Goline\<C-G>u3.1"
21 normal g;
22 call assert_equal([[
23 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
24 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
25 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
26 \ getchangelist(bufnr('%')))
27
28 hide edit Xfile2.txt
29 exe "normal 1GOline\<C-G>u1.0"
30 exe "normal 2Goline\<C-G>u2.0"
31 call assert_equal([[
32 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
33 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2],
34 \ getchangelist(bufnr('%')))
35 hide enew
36
37 call assert_equal([[
38 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
39 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
40 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 3], getchangelist(2))
41 call assert_equal([[
42 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
43 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], getchangelist(3))
44
45 bwipe!
46 call delete('Xfile1.txt')
47 call delete('Xfile2.txt')
48 endfunc