Fix #730 - Lint files on save even when nothing was fixed

This commit is contained in:
w0rp 2017-07-10 13:40:22 +01:00
parent 82dd80c692
commit b44f6053d1
2 changed files with 36 additions and 2 deletions

View File

@ -77,8 +77,6 @@ function! ale#fix#ApplyFixes(buffer, output) abort
echoerr 'The file was changed before fixing finished' echoerr 'The file was changed before fixing finished'
return return
endif endif
let l:data.done = 1
endif endif
if !bufexists(a:buffer) if !bufexists(a:buffer)
@ -86,6 +84,8 @@ function! ale#fix#ApplyFixes(buffer, output) abort
call remove(g:ale_fix_buffer_data, a:buffer) call remove(g:ale_fix_buffer_data, a:buffer)
endif endif
let l:data.done = 1
" We can only change the lines of a buffer which is currently open, " We can only change the lines of a buffer which is currently open,
" so try and apply the fixes to the current buffer. " so try and apply the fixes to the current buffer.
call ale#fix#ApplyQueuedFixes() call ale#fix#ApplyQueuedFixes()

View File

@ -86,6 +86,8 @@ After:
call delete('fix_test_file') call delete('fix_test_file')
endif endif
call setloclist(0, [])
let g:ale_fix_buffer_data = {} let g:ale_fix_buffer_data = {}
Given testft (A file with three lines): Given testft (A file with three lines):
@ -305,6 +307,38 @@ Expect(The buffer should be the same):
b b
c c
Execute(ALEFix should still lint when nothing was fixed on save):
let g:ale_fix_on_save = 1
let g:ale_lint_on_save = 1
let g:ale_enabled = 1
noautocmd silent file fix_test_file
let g:ale_fixers.testft = ['DoNothing']
call SetUpLinters()
call ale#events#SaveEvent()
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
" We have run the linter.
AssertEqual [{
\ 'bufnr': bufnr('%'),
\ 'lnum': 1,
\ 'vcol': 0,
\ 'col': 1,
\ 'text': 'xxx',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\}], getloclist(0)
Expect(The buffer should be the same):
a
b
c
Given testft (A file with three lines): Given testft (A file with three lines):
a a
b b