#653 Filter items based on the buffer number for problem counts
This commit is contained in:
parent
f67fc43d9b
commit
ae6cecabb6
2 changed files with 49 additions and 38 deletions
|
@ -22,10 +22,11 @@ function! ale#statusline#Update(buffer, loclist) abort
|
|||
return
|
||||
endif
|
||||
|
||||
let l:loclist = filter(copy(a:loclist), 'v:val.bufnr == a:buffer')
|
||||
let l:count = s:CreateCountDict()
|
||||
let l:count.total = len(a:loclist)
|
||||
let l:count.total = len(l:loclist)
|
||||
|
||||
for l:entry in a:loclist
|
||||
for l:entry in l:loclist
|
||||
if l:entry.type is# 'W'
|
||||
if get(l:entry, 'sub_type', '') is# 'style'
|
||||
let l:count.style_warning += 1
|
||||
|
|
|
@ -31,7 +31,7 @@ After:
|
|||
delfunction Counts
|
||||
|
||||
Execute (Count should be 0 when data is empty):
|
||||
AssertEqual Counts({}), ale#statusline#Count(bufnr('%'))
|
||||
AssertEqual Counts({}), ale#statusline#Count(bufnr(''))
|
||||
|
||||
Execute (Count should read data from the cache):
|
||||
let g:ale_buffer_info = {'44': {'count': Counts({'error': 1, 'warning': 2})}}
|
||||
|
@ -44,23 +44,33 @@ Execute (The count should be correct after an update):
|
|||
|
||||
Execute (Count should be match the loclist):
|
||||
let g:ale_buffer_info = {
|
||||
\ bufnr('%'): {
|
||||
\ bufnr(''): {
|
||||
\ 'loclist': [
|
||||
\ {'type': 'E'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'I'},
|
||||
\ {'bufnr': bufnr('') - 1, 'type': 'E'},
|
||||
\ {'bufnr': bufnr('') - 1, 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr('') - 1, 'type': 'W'},
|
||||
\ {'bufnr': bufnr('') - 1, 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr('') - 1, 'type': 'I'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'E'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\ {'bufnr': bufnr('') + 1, 'type': 'E'},
|
||||
\ {'bufnr': bufnr('') + 1, 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr('') + 1, 'type': 'W'},
|
||||
\ {'bufnr': bufnr('') + 1, 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr('') + 1, 'type': 'I'},
|
||||
\ ],
|
||||
\ },
|
||||
\}
|
||||
|
@ -73,46 +83,46 @@ Execute (Count should be match the loclist):
|
|||
\ '0': 3,
|
||||
\ '1': 12,
|
||||
\ 'total': 15,
|
||||
\}, ale#statusline#Count(bufnr('%'))
|
||||
\}, ale#statusline#Count(bufnr(''))
|
||||
|
||||
Execute (Output should be empty for non-existant buffer):
|
||||
AssertEqual Counts({}), ale#statusline#Count(9001)
|
||||
|
||||
Execute (Status() should return just errors for the old format):
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [
|
||||
\ {'type': 'E'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
let g:ale_buffer_info = {bufnr(''): {}}
|
||||
call ale#statusline#Update(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'type': 'E'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual '2E', ale#statusline#Status()
|
||||
|
||||
Execute (Status() should return just warnings for the old format):
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\ {'type': 'I'},
|
||||
let g:ale_buffer_info = {bufnr(''): {}}
|
||||
call ale#statusline#Update(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'type': 'W'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\])
|
||||
AssertEqual '3W', ale#statusline#Status()
|
||||
|
||||
Execute (Status() should return errors and warnings for the old format):
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [
|
||||
\ {'type': 'E'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\ {'type': 'I'},
|
||||
let g:ale_buffer_info = {bufnr(''): {}}
|
||||
call ale#statusline#Update(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'type': 'E'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
||||
\ {'bufnr': bufnr(''), 'type': 'I'},
|
||||
\])
|
||||
AssertEqual '2E 3W', ale#statusline#Status()
|
||||
|
||||
Execute (Status() should return the custom 'OK' string with the old format):
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
let g:ale_buffer_info = {bufnr('%'): {}}
|
||||
call ale#statusline#Update(bufnr('%'), [])
|
||||
let g:ale_buffer_info = {bufnr(''): {}}
|
||||
call ale#statusline#Update(bufnr(''), [])
|
||||
AssertEqual 'OKIE', ale#statusline#Status()
|
||||
|
||||
Execute(ale#statusline#Update shouldn't blow up when globals are undefined):
|
||||
|
|
Reference in a new issue