Skip to content

Commit

Permalink
Fix #1727 - Replace previoulsy defined linters with matching names
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Jun 10, 2019
1 parent 168768b commit ce91972
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions autoload/ale/linter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,14 @@ function! ale#linter#Define(filetype, linter) abort
" This command will throw from the sandbox.
let &l:equalprg=&l:equalprg

let l:new_linter = ale#linter#PreProcess(a:filetype, a:linter)

if !has_key(s:linters, a:filetype)
let s:linters[a:filetype] = []
endif

let l:new_linter = ale#linter#PreProcess(a:filetype, a:linter)

" Remove previously defined linters with the same name.
call filter(s:linters[a:filetype], 'v:val.name isnot# a:linter.name')
call add(s:linters[a:filetype], l:new_linter)
endfunction

Expand Down
8 changes: 8 additions & 0 deletions test/test_linter_retrieval.vader
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ Execute (Buffer-local overrides for aliases should be used):

AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')

Execute (Linters new linters with the same name should replace old ones):
let g:testlinter1.name = g:testlinter2.name

call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft1', g:testlinter2)

AssertEqual [g:testlinter2], ale#linter#GetAll(['testft1'])

Execute (Linters should be loaded from disk appropriately):
call ale#linter#Reset()
AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''}], ale#linter#Get('testft')
Expand Down

0 comments on commit ce91972

Please sign in to comment.