All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 let g:ale_buffer_info = {
5 \ {'type': 'E', 'bufnr': bufnr('') - 1, 'lnum': 3, 'col': 2},
6 \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 2},
7 \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 3},
8 \ {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
9 \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
10 \ {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
11 \ {'type': 'W', 'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
12 \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
13 \ {'type': 'E', 'bufnr': bufnr('') + 1, 'lnum': 3, 'col': 2},
18 function! TestJump(position, wrap, filter, subtype_filter, pos)
21 if type(a:position) == type(0)
22 call ale#loclist_jumping#JumpToIndex(a:position)
24 call ale#loclist_jumping#Jump(a:position, a:wrap, a:filter,
28 return getcurpos()[1:2]
32 let g:ale_buffer_info = {}
35 Given foobar (Some imaginary filetype):
39 Execute(loclist jumping should jump correctly when not wrapping):
40 AssertEqual [2, 1], TestJump('before', 0, 'any', 'any', [2, 2])
41 AssertEqual [1, 3], TestJump('before', 0, 'any', 'any', [2, 1])
42 AssertEqual [2, 3], TestJump('after', 0, 'any', 'any', [2, 2])
43 AssertEqual [2, 1], TestJump('after', 0, 'any', 'any', [1, 3])
44 AssertEqual [2, 6], TestJump('after', 0, 'any', 'any', [2, 4])
45 AssertEqual [2, 8], TestJump('after', 0, 'any', 'any', [2, 6])
47 Execute(loclist jumping should jump correctly when wrapping):
48 AssertEqual [2, 1], TestJump('before', 1, 'any', 'any', [2, 2])
49 AssertEqual [1, 3], TestJump('before', 1, 'any', 'any', [2, 1])
50 AssertEqual [2, 3], TestJump('after', 1, 'any', 'any', [2, 2])
51 AssertEqual [2, 1], TestJump('after', 1, 'any', 'any', [1, 3])
52 AssertEqual [2, 6], TestJump('after', 1, 'any', 'any', [2, 4])
54 AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [2, 8])
55 AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [1, 2])
57 Execute(loclist jumping should jump correctly with warning filters):
58 AssertEqual [2, 1], TestJump('after', 0, 'W', 'any', [1, 2])
59 AssertEqual [2, 6], TestJump('after', 0, 'W', 'any', [2, 3])
60 AssertEqual [2, 1], TestJump('after', 1, 'W', 'any', [2, 6])
62 Execute(loclist jumping should jump correctly with error filters):
63 AssertEqual [1, 2], TestJump('after', 1, 'E', 'any', [2, 700])
64 AssertEqual [2, 2], TestJump('before', 0, 'E', 'any', [2, 700])
65 AssertEqual [2, 2], TestJump('after', 1, 'E', 'any', [1, 3])
67 Execute(loclist jumping should jump correctly with sub type filters):
68 AssertEqual [2, 3], TestJump('after', 0, 'any', 'style', [2, 1])
69 AssertEqual [2, 2], TestJump('after', 0, 'any', '', [1, 3])
70 AssertEqual [2, 1], TestJump('after', 1, 'any', 'style', [2, 6])
72 Execute(loclist jumping not jump when the loclist is empty):
73 let g:ale_buffer_info[bufnr('%')].loclist = []
75 AssertEqual [1, 6], TestJump('before', 0, 'any', 'any', [1, 6])
76 AssertEqual [1, 6], TestJump('before', 1, 'any', 'any', [1, 6])
77 AssertEqual [1, 6], TestJump('after', 0, 'any', 'any', [1, 6])
78 AssertEqual [1, 6], TestJump('after', 1, 'any', 'any', [1, 6])
80 Execute(We should be able to jump to the last item):
81 AssertEqual [2, 8], TestJump(-1, 0, 'any', 'any', [1, 6])
83 Execute(We shouldn't move when jumping to the last item where there are none):
84 let g:ale_buffer_info[bufnr('%')].loclist = []
86 AssertEqual [1, 6], TestJump(-1, 0, 'any', 'any', [1, 6])
88 Execute(We should be able to jump to the first item):
89 AssertEqual [1, 2], TestJump(0, 0, 'any', 'any', [1, 6])
91 Execute(We shouldn't move when jumping to the first item where there are none):
92 let g:ale_buffer_info[bufnr('%')].loclist = []
94 AssertEqual [1, 6], TestJump(0, 0, 'any', 'any', [1, 6])
96 Execute(We should be able to jump when the error line is blank):
97 " Add a blank line at the end.
98 call setline(1, getline('.', '$') + [''])
99 " Add a problem on the blank line.
100 call add(g:ale_buffer_info[bufnr('%')].loclist, {'type': 'E', 'bufnr': bufnr(''), 'lnum': 3, 'col': 1})
102 AssertEqual 0, len(getline(3))
103 AssertEqual [2, 8], TestJump('before', 0, 'any', 'any', [3, 1])
104 AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [3, 1])
105 AssertEqual [3, 1], TestJump('after', 0, 'any', 'any', [3, 1])
106 AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [3, 1])
108 Execute(ALE should jump to column 1 instead of 0):
109 let g:ale_buffer_info = {
112 \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 5},
113 \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 0},
118 AssertEqual [2, 1], TestJump('after', 1, 'any', 'any', [1, 5])
119 AssertEqual [1, 5], TestJump('after', 1, 'any', 'any', [2, 1])
120 AssertEqual [2, 1], TestJump('before', 1, 'any', 'any', [1, 5])
121 AssertEqual [1, 5], TestJump('before', 1, 'any', 'any', [2, 1])