Fix #2415 - Mark tsserver and LSP linters inactive again

This commit is contained in:
w0rp 2019-04-17 18:12:25 +01:00
parent fa18195e34
commit 711de2c1be
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
4 changed files with 55 additions and 6 deletions

View File

@ -39,8 +39,8 @@ function! ale#engine#MarkLinterActive(info, linter) abort
endif endif
endfunction endfunction
function! ale#engine#MarkLinterInactive(info, linter) abort function! ale#engine#MarkLinterInactive(info, linter_name) abort
call filter(a:info.active_linter_list, 'v:val.name isnot# a:linter.name') call filter(a:info.active_linter_list, 'v:val.name isnot# a:linter_name')
endfunction endfunction
function! ale#engine#ResetExecutableCache() abort function! ale#engine#ResetExecutableCache() abort
@ -195,7 +195,7 @@ function! s:HandleExit(job_info, buffer, output, data) abort
let l:next_chain_index = a:job_info.next_chain_index let l:next_chain_index = a:job_info.next_chain_index
" Remove this job from the list. " Remove this job from the list.
call ale#engine#MarkLinterInactive(l:buffer_info, l:linter) call ale#engine#MarkLinterInactive(l:buffer_info, l:linter.name)
" Stop here if we land in the handle for a job completing if we're in " Stop here if we land in the handle for a job completing if we're in
" a sandbox. " a sandbox.

View File

@ -27,12 +27,15 @@ function! s:HandleLSPDiagnostics(conn_id, response) abort
let l:linter_name = s:lsp_linter_map[a:conn_id] let l:linter_name = s:lsp_linter_map[a:conn_id]
let l:filename = ale#path#FromURI(a:response.params.uri) let l:filename = ale#path#FromURI(a:response.params.uri)
let l:buffer = bufnr(l:filename) let l:buffer = bufnr(l:filename)
let l:info = get(g:ale_buffer_info, l:buffer, {})
if s:ShouldIgnore(l:buffer, l:linter_name) if empty(l:info)
return return
endif endif
if l:buffer <= 0 call ale#engine#MarkLinterInactive(l:info, l:linter_name)
if s:ShouldIgnore(l:buffer, l:linter_name)
return return
endif endif
@ -50,6 +53,8 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
return return
endif endif
call ale#engine#MarkLinterInactive(l:info, l:linter_name)
if s:ShouldIgnore(l:buffer, l:linter_name) if s:ShouldIgnore(l:buffer, l:linter_name)
return return
endif endif

View File

@ -5,12 +5,15 @@ Before:
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
unlet! g:ale_lsp_error_messages unlet! g:ale_lsp_error_messages
unlet! b:ale_linters
call ale#test#SetDirectory('/testplugin/test') call ale#test#SetDirectory('/testplugin/test')
After: After:
Restore Restore
unlet! b:ale_linters
call ale#test#RestoreDirectory() call ale#test#RestoreDirectory()
call ale#linter#Reset() call ale#linter#Reset()
call ale#lsp_linter#ClearLSPData() call ale#lsp_linter#ClearLSPData()
@ -162,6 +165,47 @@ Execute(tsserver semantic error responses should be handled correctly):
\ ], \ ],
\ ale#test#GetLoclistWithoutModule() \ ale#test#GetLoclistWithoutModule()
Execute(tsserver errors should mark tsserver no longer active):
let b:ale_linters = ['tsserver']
runtime ale_linters/typescript/tsserver.vim
call ale#test#SetFilename('filename.ts')
call ale#engine#InitBufferInfo(bufnr(''))
let g:ale_buffer_info[bufnr('')].active_linter_list = ale#linter#Get('typescript')
Assert !empty(g:ale_buffer_info[bufnr('')].active_linter_list)
call ale#lsp_linter#HandleLSPResponse(1, {
\ 'seq': 0,
\ 'type': 'event',
\ 'event': 'semanticDiag',
\ 'body': {
\ 'file': g:dir . '/filename.ts',
\ 'diagnostics':[],
\ },
\})
AssertEqual [], g:ale_buffer_info[bufnr('')].active_linter_list
Execute(LSP errors should mark linters no longer active):
let b:ale_linters = ['pyls']
runtime ale_linters/python/pyls.vim
call ale#test#SetFilename('filename.py')
call ale#engine#InitBufferInfo(bufnr(''))
call ale#lsp_linter#SetLSPLinterMap({1: 'pyls'})
let g:ale_buffer_info[bufnr('')].active_linter_list = ale#linter#Get('python')
Assert !empty(g:ale_buffer_info[bufnr('')].active_linter_list)
call ale#lsp_linter#HandleLSPResponse(1, {
\ 'method': 'textDocument/publishDiagnostics',
\ 'params': {
\ 'uri': ale#path#ToURI(g:dir . '/filename.py'),
\ 'diagnostics': [],
\ },
\})
AssertEqual [], g:ale_buffer_info[bufnr('')].active_linter_list
Execute(LSP errors should be logged in the history): Execute(LSP errors should be logged in the history):
call ale#lsp_linter#SetLSPLinterMap({'347': 'foobar'}) call ale#lsp_linter#SetLSPLinterMap({'347': 'foobar'})
call ale#lsp_linter#HandleLSPResponse(347, { call ale#lsp_linter#HandleLSPResponse(347, {

View File

@ -42,7 +42,7 @@ Before:
runtime autoload/ale/engine.vim runtime autoload/ale/engine.vim
let g:ale_buffer_info = {bufnr(''): {'loclist': []}} let g:ale_buffer_info = {bufnr(''): {'loclist': [], 'active_linter_list': []}}
let g:ale_handle_loclist_called = 0 let g:ale_handle_loclist_called = 0
function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort