Mercurial > vim
comparison src/testdir/test_jumplist.vim @ 13246:dd3b2ecf91f6 v8.0.1497
patch 8.0.1497: getting the jump list requires parsing the output of :jumps
commit https://github.com/vim/vim/commit/4f50588ba336e7f086a72c53f5688c2494fc34b3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 10 21:06:32 2018 +0100
patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Problem: Getting the jump list requires parsing the output of :jumps.
Solution: Add getjumplist(). (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/2609)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Feb 2018 21:15:05 +0100 |
parents | |
children | 5958573d8a72 |
comparison
equal
deleted
inserted
replaced
13245:09783cb4b108 | 13246:dd3b2ecf91f6 |
---|---|
1 " Tests for the jumplist functionality | |
2 | |
3 " Tests for the getjumplist() function | |
4 func Test_getjumplist() | |
5 if !has("jumplist") | |
6 return | |
7 endif | |
8 | |
9 %bwipe | |
10 clearjumps | |
11 call assert_equal([[], 0], getjumplist()) | |
12 call assert_equal([[], 0], getjumplist(1)) | |
13 call assert_equal([[], 0], getjumplist(1, 1)) | |
14 | |
15 call assert_equal([], getjumplist(100)) | |
16 call assert_equal([], getjumplist(1, 100)) | |
17 | |
18 let lines = [] | |
19 for i in range(1, 100) | |
20 call add(lines, "Line " . i) | |
21 endfor | |
22 call writefile(lines, "Xtest") | |
23 | |
24 " Jump around and create a jump list | |
25 edit Xtest | |
26 let bnr = bufnr('%') | |
27 normal 50% | |
28 normal G | |
29 normal gg | |
30 | |
31 call assert_equal([[ | |
32 \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
33 \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
34 \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
35 \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4], | |
36 \ getjumplist()) | |
37 | |
38 " Traverse the jump list and verify the results | |
39 5 | |
40 exe "normal \<C-O>" | |
41 call assert_equal(2, getjumplist(1)[1]) | |
42 exe "normal 2\<C-O>" | |
43 call assert_equal(0, getjumplist(1, 1)[1]) | |
44 exe "normal 3\<C-I>" | |
45 call assert_equal(3, getjumplist()[1]) | |
46 exe "normal \<C-O>" | |
47 normal 20% | |
48 call assert_equal([[ | |
49 \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
50 \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
51 \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
52 \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0}, | |
53 \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 5], | |
54 \ getjumplist()) | |
55 | |
56 let l = getjumplist() | |
57 call test_garbagecollect_now() | |
58 call assert_equal(5, l[1]) | |
59 clearjumps | |
60 call test_garbagecollect_now() | |
61 call assert_equal(5, l[1]) | |
62 | |
63 call delete("Xtest") | |
64 endfunc |