#653 - Fix loclist jumping so it works with buffer numbers

This commit is contained in:
w0rp 2017-08-12 14:49:02 +01:00
parent b300b0646d
commit e6b6146731
2 changed files with 9 additions and 8 deletions

View File

@ -14,7 +14,7 @@ function! ale#loclist_jumping#FindNearest(direction, wrap) abort
let l:info = get(g:ale_buffer_info, bufnr('%'), {'loclist': []}) let l:info = get(g:ale_buffer_info, bufnr('%'), {'loclist': []})
" This list will have already been sorted. " This list will have already been sorted.
let l:loclist = l:info.loclist let l:loclist = l:info.loclist
let l:search_item = {'lnum': l:pos[1], 'col': l:pos[2]} let l:search_item = {'bufnr': bufnr(''), 'lnum': l:pos[1], 'col': l:pos[2]}
" When searching backwards, so we can find the next smallest match. " When searching backwards, so we can find the next smallest match.
if a:direction is# 'before' if a:direction is# 'before'
@ -30,6 +30,7 @@ function! ale#loclist_jumping#FindNearest(direction, wrap) abort
" cursor to a line without changing the column, in some cases. " cursor to a line without changing the column, in some cases.
let l:cmp_value = ale#util#LocItemCompare( let l:cmp_value = ale#util#LocItemCompare(
\ { \ {
\ 'bufnr': bufnr(''),
\ 'lnum': l:item.lnum, \ 'lnum': l:item.lnum,
\ 'col': min([max([l:item.col, 1]), len(getline(l:item.lnum))]), \ 'col': min([max([l:item.col, 1]), len(getline(l:item.lnum))]),
\ }, \ },

View File

@ -2,13 +2,13 @@ Before:
let g:ale_buffer_info = { let g:ale_buffer_info = {
\ bufnr('%'): { \ bufnr('%'): {
\ 'loclist': [ \ 'loclist': [
\ {'lnum': 1, 'col': 2}, \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 2},
\ {'lnum': 1, 'col': 3}, \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 3},
\ {'lnum': 2, 'col': 1}, \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
\ {'lnum': 2, 'col': 2}, \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
\ {'lnum': 2, 'col': 3}, \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
\ {'lnum': 2, 'col': 6}, \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
\ {'lnum': 2, 'col': 700}, \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
\ ], \ ],
\ }, \ },
\} \}