Skip to content

Commit

Permalink
Fix #730 - Lint files on save even when nothing was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Jul 10, 2017
1 parent 74f2afb commit bd0f311
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions autoload/ale/fix.vim
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ function! ale#fix#ApplyFixes(buffer, output) abort
echoerr 'The file was changed before fixing finished'
return
endif

let l:data.done = 1
endif

if !bufexists(a:buffer)
" Remove the buffer data when it doesn't exist.
call remove(g:ale_fix_buffer_data, a:buffer)
endif

let l:data.done = 1

" We can only change the lines of a buffer which is currently open,
" so try and apply the fixes to the current buffer.
call ale#fix#ApplyQueuedFixes()
Expand Down
34 changes: 34 additions & 0 deletions test/test_ale_fix.vader
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ After:
call delete('fix_test_file')
endif

call setloclist(0, [])

let g:ale_fix_buffer_data = {}

Given testft (A file with three lines):
Expand Down Expand Up @@ -305,6 +307,38 @@ Expect(The buffer should be the same):
b
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):
a
b
Expand Down

0 comments on commit bd0f311

Please sign in to comment.