mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Close #1494 - Prefer displaying higher severity problems for cursor messages, balloons, and highlights
This commit is contained in:
@@ -7,10 +7,19 @@ Before:
|
||||
|
||||
let g:ale_buffer_info[bufnr('')] = {'loclist': [
|
||||
\ {
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 10,
|
||||
\ 'linter_name': 'eslint',
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'Ignore me.',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 10,
|
||||
\ 'text': 'Missing semicolon. (semi)',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': bufnr(''),
|
||||
|
||||
@@ -2,6 +2,7 @@ Before:
|
||||
Save g:ale_echo_msg_format
|
||||
Save g:ale_echo_cursor
|
||||
|
||||
" We should prefer the error message at column 10 instead of the warning.
|
||||
let g:ale_buffer_info = {
|
||||
\ bufnr('%'): {
|
||||
\ 'loclist': [
|
||||
@@ -12,6 +13,17 @@ Before:
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'eslint',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'W',
|
||||
\ 'code': 'semi',
|
||||
\ 'text': 'Ignore me.',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 10,
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'eslint',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'E',
|
||||
\ 'code': 'semi',
|
||||
\ 'text': 'Missing semicolon.',
|
||||
|
||||
@@ -47,3 +47,20 @@ 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)
|
||||
|
||||
Execute(Searches should return the last item on a single column):
|
||||
let g:loclist = [
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 10, 'type': 'W'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 10, 'type': 'E'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 11, 'type': 'W'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 11, 'type': 'E'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 20, 'type': 'W'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 20, 'type': 'E'},
|
||||
\]
|
||||
|
||||
" We should return the index for the last item at some column to the right.
|
||||
AssertEqual 1, ale#util#BinarySearch(g:loclist, 1, 1, 1)
|
||||
" We should return the index for the last item at the column we are on.
|
||||
AssertEqual 3, ale#util#BinarySearch(g:loclist, 1, 1, 11)
|
||||
" We should prefer items to the left of the cursor, over the right.
|
||||
AssertEqual 3, ale#util#BinarySearch(g:loclist, 1, 1, 19)
|
||||
|
||||
@@ -2,15 +2,15 @@ Before:
|
||||
let g:ale_buffer_info = {
|
||||
\ bufnr(''): {
|
||||
\ 'loclist': [
|
||||
\ {'bufnr': bufnr('') - 1, 'lnum': 3, 'col': 2},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 2},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 3},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
|
||||
\ {'bufnr': bufnr('') + 1, 'lnum': 3, 'col': 2},
|
||||
\ {'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},
|
||||
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
|
||||
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
|
||||
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
|
||||
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
|
||||
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
|
||||
\ {'type': 'E', 'bufnr': bufnr('') + 1, 'lnum': 3, 'col': 2},
|
||||
\ ],
|
||||
\ },
|
||||
\}
|
||||
@@ -81,7 +81,7 @@ Execute(We should be able to jump when the error line is blank):
|
||||
" Add a blank line at the end.
|
||||
call setline(1, getline('.', '$') + [''])
|
||||
" Add a problem on the blank line.
|
||||
call add(g:ale_buffer_info[bufnr('%')].loclist, {'bufnr': bufnr(''), 'lnum': 3, 'col': 1})
|
||||
call add(g:ale_buffer_info[bufnr('%')].loclist, {'type': 'E', 'bufnr': bufnr(''), 'lnum': 3, 'col': 1})
|
||||
|
||||
AssertEqual 0, len(getline(3))
|
||||
AssertEqual [2, 8], TestJump('before', 0, [3, 1])
|
||||
|
||||
@@ -25,3 +25,19 @@ Execute(loclist item should be sorted):
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 2},
|
||||
\ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2},
|
||||
\], 'ale#util#LocItemCompare')
|
||||
|
||||
Execute(Items should be sorted in by their problem priority when they lie on the same column):
|
||||
AssertEqual [
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'I'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'W'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'E'},
|
||||
\ ],
|
||||
\ sort([
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'E'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'I'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'W'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': 1, 'lnum': 1, 'col': 1, 'type': 'W', 'sub_type': 'style'},
|
||||
\], 'ale#util#LocItemCompare')
|
||||
|
||||
@@ -9,42 +9,42 @@ Execute:
|
||||
" Equal problems should be de-duplicated.
|
||||
let g:ale_buffer_info = {
|
||||
\ '1': {'loclist': [
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
|
||||
\ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
|
||||
\ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'foo'},
|
||||
\ {'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
|
||||
\ {'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': 3, 'lnum': 1, 'col': 1, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
|
||||
\ {'type': 'E', 'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 3, 'lnum': 1, 'col': 1, 'text': 'foo'},
|
||||
\ ]},
|
||||
\ '2': {'loclist': [
|
||||
\ {'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
|
||||
\ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'another error'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'another error'},
|
||||
\ ]},
|
||||
\}
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
|
||||
\ {'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
|
||||
\ {'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
|
||||
\ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'another error'},
|
||||
\ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'foo'},
|
||||
\ {'bufnr': 3, 'lnum': 1, 'col': 1, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'another error'},
|
||||
\ {'type': 'E', 'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'foo'},
|
||||
\ {'type': 'E', 'bufnr': 3, 'lnum': 1, 'col': 1, 'text': 'foo'},
|
||||
\ ],
|
||||
\ ale#list#GetCombinedList()
|
||||
|
||||
Reference in New Issue
Block a user