mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 13:02:28 +08:00
#653 - Update the loclist binary search to work with buffer numbers, to filter out items for other buffers
This commit is contained in:
@@ -3,16 +3,19 @@ Before:
|
||||
|
||||
let g:ale_buffer_info[347] = {'loclist': [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 10,
|
||||
\ 'text': 'Missing semicolon. (semi)',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 10,
|
||||
\ 'text': 'Infix operators must be spaced. (space-infix-ops)'
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 15,
|
||||
\ 'text': 'Missing radix parameter (radix)'
|
||||
|
||||
@@ -1,26 +1,49 @@
|
||||
Before:
|
||||
let g:loclist = [
|
||||
\ {'lnum': 2, 'col': 10},
|
||||
\ {'lnum': 3, 'col': 2},
|
||||
\ {'lnum': 3, 'col': 10},
|
||||
\ {'lnum': 3, 'col': 12},
|
||||
\ {'lnum': 3, 'col': 25},
|
||||
\ {'lnum': 5, 'col': 4},
|
||||
\ {'lnum': 5, 'col': 5},
|
||||
\ {'bufnr': 1, 'lnum': 2, 'col': 10},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 2},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 10},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 12},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 25},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 4},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 5},
|
||||
\ {'bufnr': 1, 'lnum': 9, 'col': 5},
|
||||
\ {'bufnr': 1, 'lnum': 10, 'col': 1},
|
||||
\ {'bufnr': 2, 'lnum': 7, 'col': 10},
|
||||
\ {'bufnr': 2, 'lnum': 9, 'col': 2},
|
||||
\ {'bufnr': 2, 'lnum': 10, 'col': 2},
|
||||
\ {'bufnr': 2, 'lnum': 11, 'col': 2},
|
||||
\]
|
||||
|
||||
Execute (Exact column matches should be correct):
|
||||
AssertEqual 1, ale#util#BinarySearch(g:loclist, 3, 2)
|
||||
|
||||
Execute (Off lines, there should be no match):
|
||||
AssertEqual -1, ale#util#BinarySearch(g:loclist, 4, 2)
|
||||
|
||||
Execute (Near column matches should be taken):
|
||||
AssertEqual 2, ale#util#BinarySearch(g:loclist, 3, 11)
|
||||
AssertEqual 4, ale#util#BinarySearch(g:loclist, 3, 13)
|
||||
|
||||
Execute (Columns before should be taken when the cursor is far ahead):
|
||||
AssertEqual 4, ale#util#BinarySearch(g:loclist, 3, 300)
|
||||
|
||||
After:
|
||||
unlet g:loclist
|
||||
|
||||
Execute(Exact column matches should be correct):
|
||||
AssertEqual 1, ale#util#BinarySearch(g:loclist, 1, 3, 2)
|
||||
|
||||
Execute(Off lines, there should be no match):
|
||||
AssertEqual -1, ale#util#BinarySearch(g:loclist, 1, 4, 2)
|
||||
|
||||
Execute(Near column matches should be taken):
|
||||
AssertEqual 2, ale#util#BinarySearch(g:loclist, 1, 3, 11)
|
||||
AssertEqual 3, ale#util#BinarySearch(g:loclist, 1, 3, 13)
|
||||
|
||||
Execute(Columns before should be taken when the cursor is far ahead):
|
||||
AssertEqual 4, ale#util#BinarySearch(g:loclist, 1, 3, 300)
|
||||
|
||||
Execute(The only problems on lines in later columns should be matched):
|
||||
AssertEqual 7, ale#util#BinarySearch(g:loclist, 1, 9, 1)
|
||||
|
||||
Execute(The only problems on lines in earlier columns should be matched):
|
||||
AssertEqual 8, ale#util#BinarySearch(g:loclist, 1, 10, 30)
|
||||
|
||||
Execute(Lines for other buffers should not be matched):
|
||||
AssertEqual -1, ale#util#BinarySearch(g:loclist, 1, 7, 10)
|
||||
|
||||
Execute(Searches for buffers later in the list should work):
|
||||
AssertEqual 10, ale#util#BinarySearch(g:loclist, 2, 9, 10)
|
||||
|
||||
Execute(Searches should work with just one item):
|
||||
let g:loclist = [{'bufnr': 1, 'lnum': 3, 'col': 10}]
|
||||
|
||||
AssertEqual 0, ale#util#BinarySearch(g:loclist, 1, 3, 2)
|
||||
|
||||
Reference in New Issue
Block a user