Fix counting of warnings and style warnings

This commit is contained in:
w0rp 2017-05-21 18:58:26 +01:00
parent d511b02ebe
commit 57ad32f986
2 changed files with 27 additions and 13 deletions

View File

@ -28,9 +28,9 @@ function! ale#statusline#Update(buffer, loclist) abort
for l:entry in a:loclist for l:entry in a:loclist
if l:entry.type ==# 'W' if l:entry.type ==# 'W'
if get(l:entry, 'sub_type', '') ==# 'style' if get(l:entry, 'sub_type', '') ==# 'style'
let l:count.warning += 1
else
let l:count.style_warning += 1 let l:count.style_warning += 1
else
let l:count.warning += 1
endif endif
elseif l:entry.type ==# 'I' elseif l:entry.type ==# 'I'
let l:count.info += 1 let l:count.info += 1

View File

@ -46,20 +46,34 @@ Execute (Count should be match the loclist):
let g:ale_buffer_info = { let g:ale_buffer_info = {
\ bufnr('%'): { \ bufnr('%'): {
\ 'loclist': [ \ 'loclist': [
\ { \ {'type': 'E'},
\ 'lnum': 1, \ {'type': 'E', 'sub_type': 'style'},
\ 'bufnr': 1, \ {'type': 'E', 'sub_type': 'style'},
\ 'vcol': 0, \ {'type': 'W'},
\ 'linter_name': 'testlinter', \ {'type': 'W'},
\ 'nr': -1, \ {'type': 'W'},
\ 'type': 'E', \ {'type': 'W', 'sub_type': 'style'},
\ 'col': 1, \ {'type': 'W', 'sub_type': 'style'},
\ 'text': 'Test Error', \ {'type': 'W', 'sub_type': 'style'},
\ }, \ {'type': 'W', 'sub_type': 'style'},
\ {'type': 'I'},
\ {'type': 'I'},
\ {'type': 'I'},
\ {'type': 'I'},
\ {'type': 'I'},
\ ], \ ],
\ }, \ },
\} \}
AssertEqual Counts({'error': 1}), ale#statusline#Count(bufnr('%')) AssertEqual {
\ 'error': 1,
\ 'style_error': 2,
\ 'warning': 3,
\ 'style_warning': 4,
\ 'info': 5,
\ '0': 3,
\ '1': 12,
\ 'total': 15,
\}, ale#statusline#Count(bufnr('%'))
Execute (Output should be empty for non-existant buffer): Execute (Output should be empty for non-existant buffer):
AssertEqual Counts({}), ale#statusline#Count(9001) AssertEqual Counts({}), ale#statusline#Count(9001)