summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-07-10 13:40:22 +0100
committerw0rp <devw0rp@gmail.com>2017-07-10 13:41:38 +0100
commitbd0f31147e418ed51c0327f5bcc0fc4802c15120 (patch)
treec08ab0252ceaee77d95303a3cfdeb29d5be5e960
parent74f2afbe2e51aa6407ea491dee796f4540064963 (diff)
downloadale-bd0f31147e418ed51c0327f5bcc0fc4802c15120.zip
Fix #730 - Lint files on save even when nothing was fixed
-rw-r--r--autoload/ale/fix.vim4
-rw-r--r--test/test_ale_fix.vader34
2 files changed, 36 insertions, 2 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 9ecacd12..45855a50 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -77,8 +77,6 @@ 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)
@@ -86,6 +84,8 @@ function! ale#fix#ApplyFixes(buffer, output) abort
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()
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader
index f7c6d69f..d7c3fb35 100644
--- a/test/test_ale_fix.vader
+++ b/test/test_ale_fix.vader
@@ -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):
@@ -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