mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add a unit test for the loclist comparison function.
This commit is contained in:
@@ -103,7 +103,7 @@ function! s:HandleExit(job) abort
|
||||
" Sort the loclist again.
|
||||
" We need a sorted list so we can run a binary search against it
|
||||
" for efficient lookup of the messages in the cursor handler.
|
||||
call sort(g:ale_buffer_loclist_map[l:buffer], 's:LocItemCompare')
|
||||
call sort(g:ale_buffer_loclist_map[l:buffer], 'ale#util#LocItemCompare')
|
||||
|
||||
if g:ale_set_loclist
|
||||
call setloclist(0, g:ale_buffer_loclist_map[l:buffer])
|
||||
@@ -149,26 +149,6 @@ function! s:FixLocList(buffer, loclist) abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:LocItemCompare(left, right) abort
|
||||
if a:left['lnum'] < a:right['lnum']
|
||||
return -1
|
||||
endif
|
||||
|
||||
if a:left['lnum'] > a:right['lnum']
|
||||
return 1
|
||||
endif
|
||||
|
||||
if a:left['col'] < a:right['col']
|
||||
return -1
|
||||
endif
|
||||
|
||||
if a:left['col'] > a:right['col']
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! ale#engine#Invoke(buffer, linter) abort
|
||||
if has_key(a:linter, 'job')
|
||||
" Stop previous jobs for the same linter.
|
||||
|
||||
@@ -43,3 +43,23 @@ function! ale#util#GetFunction(string_or_ref) abort
|
||||
|
||||
return a:string_or_ref
|
||||
endfunction
|
||||
|
||||
function! ale#util#LocItemCompare(left, right) abort
|
||||
if a:left['lnum'] < a:right['lnum']
|
||||
return -1
|
||||
endif
|
||||
|
||||
if a:left['lnum'] > a:right['lnum']
|
||||
return 1
|
||||
endif
|
||||
|
||||
if a:left['col'] < a:right['col']
|
||||
return -1
|
||||
endif
|
||||
|
||||
if a:left['col'] > a:right['col']
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user