2017-02-21 07:46:07 -05:00
|
|
|
Before:
|
2017-03-07 18:31:25 -05:00
|
|
|
let g:ale_buffer_info = {
|
2017-08-13 08:02:59 -04:00
|
|
|
\ bufnr(''): {
|
2017-03-07 18:31:25 -05:00
|
|
|
\ 'loclist': [
|
2018-04-10 16:05:22 -04:00
|
|
|
\ {'type': 'E', 'bufnr': bufnr('') - 1, 'lnum': 3, 'col': 2},
|
|
|
|
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 2},
|
|
|
|
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 3},
|
2019-02-10 06:11:29 -05:00
|
|
|
\ {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
|
2018-04-10 16:05:22 -04:00
|
|
|
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
|
2019-02-10 06:11:29 -05:00
|
|
|
\ {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
|
|
|
|
\ {'type': 'W', 'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
|
2018-04-10 16:05:22 -04:00
|
|
|
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
|
|
|
|
\ {'type': 'E', 'bufnr': bufnr('') + 1, 'lnum': 3, 'col': 2},
|
2017-03-07 18:31:25 -05:00
|
|
|
\ ],
|
|
|
|
\ },
|
|
|
|
\}
|
|
|
|
|
2019-02-10 06:11:29 -05:00
|
|
|
function! TestJump(position, wrap, filter, subtype_filter, pos)
|
2017-03-07 18:31:25 -05:00
|
|
|
call cursor(a:pos)
|
2017-06-03 07:45:52 -04:00
|
|
|
|
|
|
|
if type(a:position) == type(0)
|
|
|
|
call ale#loclist_jumping#JumpToIndex(a:position)
|
|
|
|
else
|
2019-02-10 06:11:29 -05:00
|
|
|
call ale#loclist_jumping#Jump(a:position, a:wrap, a:filter,
|
|
|
|
\ a:subtype_filter)
|
2017-06-03 07:45:52 -04:00
|
|
|
endif
|
2017-03-07 18:31:25 -05:00
|
|
|
|
|
|
|
return getcurpos()[1:2]
|
2017-02-21 07:46:07 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
After:
|
2017-03-07 18:31:25 -05:00
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
delfunction TestJump
|
|
|
|
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
12345678
|
|
|
|
12345678
|
|
|
|
|
|
|
|
Execute(loclist jumping should jump correctly when not wrapping):
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [2, 1], TestJump('before', 0, 'any', 'any', [2, 2])
|
|
|
|
AssertEqual [1, 3], TestJump('before', 0, 'any', 'any', [2, 1])
|
|
|
|
AssertEqual [2, 3], TestJump('after', 0, 'any', 'any', [2, 2])
|
|
|
|
AssertEqual [2, 1], TestJump('after', 0, 'any', 'any', [1, 3])
|
|
|
|
AssertEqual [2, 6], TestJump('after', 0, 'any', 'any', [2, 4])
|
|
|
|
AssertEqual [2, 8], TestJump('after', 0, 'any', 'any', [2, 6])
|
2017-03-07 18:31:25 -05:00
|
|
|
|
|
|
|
Execute(loclist jumping should jump correctly when wrapping):
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [2, 1], TestJump('before', 1, 'any', 'any', [2, 2])
|
|
|
|
AssertEqual [1, 3], TestJump('before', 1, 'any', 'any', [2, 1])
|
|
|
|
AssertEqual [2, 3], TestJump('after', 1, 'any', 'any', [2, 2])
|
|
|
|
AssertEqual [2, 1], TestJump('after', 1, 'any', 'any', [1, 3])
|
|
|
|
AssertEqual [2, 6], TestJump('after', 1, 'any', 'any', [2, 4])
|
|
|
|
|
|
|
|
AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [2, 8])
|
|
|
|
AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [1, 2])
|
|
|
|
|
|
|
|
Execute(loclist jumping should jump correctly with warning filters):
|
|
|
|
AssertEqual [2, 1], TestJump('after', 0, 'W', 'any', [1, 2])
|
|
|
|
AssertEqual [2, 6], TestJump('after', 0, 'W', 'any', [2, 3])
|
|
|
|
AssertEqual [2, 1], TestJump('after', 1, 'W', 'any', [2, 6])
|
|
|
|
|
|
|
|
Execute(loclist jumping should jump correctly with error filters):
|
|
|
|
AssertEqual [1, 2], TestJump('after', 1, 'E', 'any', [2, 700])
|
|
|
|
AssertEqual [2, 2], TestJump('before', 0, 'E', 'any', [2, 700])
|
|
|
|
AssertEqual [2, 2], TestJump('after', 1, 'E', 'any', [1, 3])
|
|
|
|
|
|
|
|
Execute(loclist jumping should jump correctly with sub type filters):
|
|
|
|
AssertEqual [2, 3], TestJump('after', 0, 'any', 'style', [2, 1])
|
|
|
|
AssertEqual [2, 2], TestJump('after', 0, 'any', '', [1, 3])
|
|
|
|
AssertEqual [2, 1], TestJump('after', 1, 'any', 'style', [2, 6])
|
2017-03-07 18:31:25 -05:00
|
|
|
|
|
|
|
Execute(loclist jumping not jump when the loclist is empty):
|
|
|
|
let g:ale_buffer_info[bufnr('%')].loclist = []
|
|
|
|
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [1, 6], TestJump('before', 0, 'any', 'any', [1, 6])
|
|
|
|
AssertEqual [1, 6], TestJump('before', 1, 'any', 'any', [1, 6])
|
|
|
|
AssertEqual [1, 6], TestJump('after', 0, 'any', 'any', [1, 6])
|
|
|
|
AssertEqual [1, 6], TestJump('after', 1, 'any', 'any', [1, 6])
|
2017-06-03 07:45:52 -04:00
|
|
|
|
|
|
|
Execute(We should be able to jump to the last item):
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [2, 8], TestJump(-1, 0, 'any', 'any', [1, 6])
|
2017-06-03 07:45:52 -04:00
|
|
|
|
|
|
|
Execute(We shouldn't move when jumping to the last item where there are none):
|
|
|
|
let g:ale_buffer_info[bufnr('%')].loclist = []
|
|
|
|
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [1, 6], TestJump(-1, 0, 'any', 'any', [1, 6])
|
2017-06-03 07:45:52 -04:00
|
|
|
|
|
|
|
Execute(We should be able to jump to the first item):
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [1, 2], TestJump(0, 0, 'any', 'any', [1, 6])
|
2017-06-03 07:45:52 -04:00
|
|
|
|
|
|
|
Execute(We shouldn't move when jumping to the first item where there are none):
|
|
|
|
let g:ale_buffer_info[bufnr('%')].loclist = []
|
|
|
|
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [1, 6], TestJump(0, 0, 'any', 'any', [1, 6])
|
2017-08-13 04:56:41 -04:00
|
|
|
|
|
|
|
Execute(We should be able to jump when the error line is blank):
|
2017-08-13 08:02:59 -04:00
|
|
|
" Add a blank line at the end.
|
|
|
|
call setline(1, getline('.', '$') + [''])
|
|
|
|
" Add a problem on the blank line.
|
2018-04-10 16:05:22 -04:00
|
|
|
call add(g:ale_buffer_info[bufnr('%')].loclist, {'type': 'E', 'bufnr': bufnr(''), 'lnum': 3, 'col': 1})
|
2017-08-13 04:56:41 -04:00
|
|
|
|
|
|
|
AssertEqual 0, len(getline(3))
|
2019-02-10 06:11:29 -05:00
|
|
|
AssertEqual [2, 8], TestJump('before', 0, 'any', 'any', [3, 1])
|
|
|
|
AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [3, 1])
|
|
|
|
AssertEqual [3, 1], TestJump('after', 0, 'any', 'any', [3, 1])
|
|
|
|
AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [3, 1])
|