Add :ALEFirst and :ALELast commands (#616)

* Add :ALEFirst and :ALELast commands

* Add documentation for ALEFirst and ALELast commands

* Add tests for ale#loclist_jumping#JumpToIndex()

* Fix the loclist jumping tests
This commit is contained in:
Drew Neil
2017-06-03 12:45:52 +01:00
committed by w0rp
parent fcb5718712
commit 33b0852c84
4 changed files with 47 additions and 2 deletions

View File

@@ -13,9 +13,14 @@ Before:
\ },
\}
function! TestJump(direction, wrap, pos)
function! TestJump(position, wrap, pos)
call cursor(a:pos)
call ale#loclist_jumping#Jump(a:direction, a:wrap)
if type(a:position) == type(0)
call ale#loclist_jumping#JumpToIndex(a:position)
else
call ale#loclist_jumping#Jump(a:position, a:wrap)
endif
return getcurpos()[1:2]
endfunction
@@ -53,3 +58,19 @@ Execute(loclist jumping not jump when the loclist is empty):
AssertEqual [1, 6], TestJump('before', 1, [1, 6])
AssertEqual [1, 6], TestJump('after', 0, [1, 6])
AssertEqual [1, 6], TestJump('after', 1, [1, 6])
Execute(We should be able to jump to the last item):
AssertEqual [2, 8], TestJump(-1, 0, [1, 6])
Execute(We shouldn't move when jumping to the last item where there are none):
let g:ale_buffer_info[bufnr('%')].loclist = []
AssertEqual [1, 6], TestJump(-1, 0, [1, 6])
Execute(We should be able to jump to the first item):
AssertEqual [1, 2], TestJump(0, 0, [1, 6])
Execute(We shouldn't move when jumping to the first item where there are none):
let g:ale_buffer_info[bufnr('%')].loclist = []
AssertEqual [1, 6], TestJump(0, 0, [1, 6])