#274 - Fix airline integration when ALE is not loaded fully
This commit is contained in:
parent
c0814934af
commit
f39e88cfa8
@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
" Update the buffer error/warning count with data from loclist.
|
" Update the buffer error/warning count with data from loclist.
|
||||||
function! ale#statusline#Update(buffer, loclist) abort
|
function! ale#statusline#Update(buffer, loclist) abort
|
||||||
|
if !exists('g:ale_buffer_info')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
if !has_key(g:ale_buffer_info, a:buffer)
|
if !has_key(g:ale_buffer_info, a:buffer)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -39,6 +43,10 @@ endfunction
|
|||||||
|
|
||||||
" Returns a tuple of errors and warnings for use in third-party integrations.
|
" Returns a tuple of errors and warnings for use in third-party integrations.
|
||||||
function! ale#statusline#Count(buffer) abort
|
function! ale#statusline#Count(buffer) abort
|
||||||
|
if !exists('g:ale_buffer_info')
|
||||||
|
return [0, 0]
|
||||||
|
endif
|
||||||
|
|
||||||
if !s:SetupCount(a:buffer)
|
if !s:SetupCount(a:buffer)
|
||||||
return [0, 0]
|
return [0, 0]
|
||||||
endif
|
endif
|
||||||
@ -48,6 +56,10 @@ endfunction
|
|||||||
|
|
||||||
" Returns a formatted string that can be integrated in the statusline.
|
" Returns a formatted string that can be integrated in the statusline.
|
||||||
function! ale#statusline#Status() abort
|
function! ale#statusline#Status() abort
|
||||||
|
if !exists('g:ale_buffer_info')
|
||||||
|
return 'OK'
|
||||||
|
endif
|
||||||
|
|
||||||
let [l:error_format, l:warning_format, l:no_errors] = g:ale_statusline_format
|
let [l:error_format, l:warning_format, l:no_errors] = g:ale_statusline_format
|
||||||
let l:buffer = bufnr('%')
|
let l:buffer = bufnr('%')
|
||||||
|
|
||||||
|
19
test/test_statusline_api_without_globals.vader
Normal file
19
test/test_statusline_api_without_globals.vader
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
" This file tests that statusline functions return meaningful output even
|
||||||
|
" when most of ALE itself has not been loaded.
|
||||||
|
"
|
||||||
|
" This is important for plugins which integrate with ALE like airline.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
unlet! g:ale_buffer_info
|
||||||
|
|
||||||
|
After:
|
||||||
|
let g:ale_buffer_info = {}
|
||||||
|
|
||||||
|
Execute(ale#statusline#Update shouldn't blow up when globals are undefined):
|
||||||
|
call ale#statusline#Update(1, [])
|
||||||
|
|
||||||
|
Execute(ale#statusline#Count should return 0 counts when globals are undefined):
|
||||||
|
AssertEqual [0, 0], ale#statusline#Count(1)
|
||||||
|
|
||||||
|
Execute(ale#statusline#Status should return 'OK' when globals are undefined):
|
||||||
|
AssertEqual 'OK', ale#statusline#Status()
|
Loading…
Reference in New Issue
Block a user