#734 - Do not clear file linter results when no buffers are run
This commit is contained in:
parent
7c32ef104b
commit
ec82530247
@ -667,25 +667,26 @@ function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort
|
|||||||
call s:StopCurrentJobs(a:buffer, a:should_lint_file)
|
call s:StopCurrentJobs(a:buffer, a:should_lint_file)
|
||||||
call s:RemoveProblemsForDisabledLinters(a:buffer, a:linters)
|
call s:RemoveProblemsForDisabledLinters(a:buffer, a:linters)
|
||||||
|
|
||||||
let l:any_linter_ran = 0
|
" We can only clear the results if we aren't checking the buffer.
|
||||||
|
let l:can_clear_results = !ale#engine#IsCheckingBuffer(a:buffer)
|
||||||
|
|
||||||
for l:linter in a:linters
|
for l:linter in a:linters
|
||||||
" Skip linters for checking files if we shouldn't check the file.
|
" Only run lint_file linters if we should.
|
||||||
if l:linter.lint_file && !a:should_lint_file
|
if !l:linter.lint_file || a:should_lint_file
|
||||||
continue
|
if s:RunLinter(a:buffer, l:linter)
|
||||||
endif
|
" If a single linter ran, we shouldn't clear everything.
|
||||||
|
let l:can_clear_results = 0
|
||||||
if s:RunLinter(a:buffer, l:linter)
|
endif
|
||||||
let l:any_linter_ran = 1
|
else
|
||||||
|
" If we skipped running a lint_file linter still in the list,
|
||||||
|
" we shouldn't clear everything.
|
||||||
|
let l:can_clear_results = 0
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" If we didn't manage to start checking the buffer with anything,
|
" Clear the results if we can. This needs to be done when linters are
|
||||||
" and there's nothing running currently for the buffer, then clear the
|
" disabled, or ALE itself is disabled.
|
||||||
" results.
|
if l:can_clear_results
|
||||||
"
|
|
||||||
" We need to use both checks, as we run some tests synchronously.
|
|
||||||
if !l:any_linter_ran && !ale#engine#IsCheckingBuffer(a:buffer)
|
|
||||||
call ale#engine#SetResults(a:buffer, [])
|
call ale#engine#SetResults(a:buffer, [])
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
Before:
|
Before:
|
||||||
Save g:ale_run_synchronously
|
Save g:ale_run_synchronously
|
||||||
|
Save g:ale_buffer_info
|
||||||
|
Save g:ale_linters
|
||||||
|
|
||||||
|
let g:ale_buffer_info = {}
|
||||||
let g:ale_run_synchronously = 1
|
let g:ale_run_synchronously = 1
|
||||||
|
call ale#ResetLintFileMarkers()
|
||||||
|
|
||||||
let g:buffer_result = [
|
let g:buffer_result = [
|
||||||
\ {
|
\ {
|
||||||
@ -95,8 +100,6 @@ Given foobar (Some imaginary filetype):
|
|||||||
baz
|
baz
|
||||||
|
|
||||||
Execute(Running linters without 'lint_file' should run only buffer linters):
|
Execute(Running linters without 'lint_file' should run only buffer linters):
|
||||||
call ale#ResetLintFileMarkers()
|
|
||||||
let g:ale_buffer_info = {}
|
|
||||||
call ale#Queue(0)
|
call ale#Queue(0)
|
||||||
|
|
||||||
AssertEqual [
|
AssertEqual [
|
||||||
@ -115,9 +118,6 @@ Execute(Running linters without 'lint_file' should run only buffer linters):
|
|||||||
\], GetSimplerLoclist()
|
\], GetSimplerLoclist()
|
||||||
|
|
||||||
Execute(Running linters with 'lint_file' should run all linters):
|
Execute(Running linters with 'lint_file' should run all linters):
|
||||||
call ale#ResetLintFileMarkers()
|
|
||||||
let g:ale_buffer_info = {}
|
|
||||||
|
|
||||||
Assert filereadable(expand('%:p')), 'The file was not readable'
|
Assert filereadable(expand('%:p')), 'The file was not readable'
|
||||||
|
|
||||||
call ale#Queue(0, 'lint_file')
|
call ale#Queue(0, 'lint_file')
|
||||||
@ -150,9 +150,6 @@ Execute(Running linters with 'lint_file' should run all linters):
|
|||||||
\], GetSimplerLoclist()
|
\], GetSimplerLoclist()
|
||||||
|
|
||||||
Execute(Linter errors from files should be kept):
|
Execute(Linter errors from files should be kept):
|
||||||
call ale#ResetLintFileMarkers()
|
|
||||||
let g:ale_buffer_info = {}
|
|
||||||
|
|
||||||
Assert filereadable(expand('%:p')), 'The file was not readable'
|
Assert filereadable(expand('%:p')), 'The file was not readable'
|
||||||
|
|
||||||
call ale#Queue(0, 'lint_file')
|
call ale#Queue(0, 'lint_file')
|
||||||
@ -189,3 +186,41 @@ Execute(Linter errors from files should be kept):
|
|||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ },
|
\ },
|
||||||
\], GetSimplerLoclist()
|
\], GetSimplerLoclist()
|
||||||
|
|
||||||
|
Execute(Linter errors from files should be kept when no other linters are run):
|
||||||
|
let g:ale_linters = {'foobar': ['lint_file_linter']}
|
||||||
|
Assert filereadable(expand('%:p')), 'The file was not readable'
|
||||||
|
|
||||||
|
call ale#Queue(0, 'lint_file')
|
||||||
|
|
||||||
|
AssertEqual [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'file warning',
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 2,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'file error',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\], GetSimplerLoclist()
|
||||||
|
|
||||||
|
call ale#Queue(0)
|
||||||
|
|
||||||
|
AssertEqual [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'file warning',
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 2,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'file error',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\], GetSimplerLoclist()
|
||||||
|
Loading…
Reference in New Issue
Block a user