summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix.vim2
-rw-r--r--test/fix/test_ale_fix.vader48
2 files changed, 49 insertions, 1 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 2b9555bf..9987fbdd 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -54,7 +54,7 @@ function! ale#fix#ApplyQueuedFixes(buffer) abort
endif
if l:data.should_save
- let l:should_lint = g:ale_fix_on_save
+ let l:should_lint = ale#Var(a:buffer, 'fix_on_save')
\ && ale#Var(a:buffer, 'lint_on_save')
else
let l:should_lint = l:data.changes_made
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader
index 05cc4457..9dd04213 100644
--- a/test/fix/test_ale_fix.vader
+++ b/test/fix/test_ale_fix.vader
@@ -525,6 +525,54 @@ Expect(The buffer should be modified):
$b
$c
+Given testft (A file with three lines):
+ a
+ b
+ c
+
+Execute(ALEFix should run the linters with b:ale_lint_on_save = 1):
+ let g:ale_fix_on_save = 0
+ let b:ale_fix_on_save = 1
+ let g:ale_lint_on_save = 1
+ let g:ale_enabled = 1
+
+ let g:test_filename = tempname()
+ execute 'noautocmd silent file ' . fnameescape(g:test_filename)
+ call writefile(getline(1, '$'), g:test_filename)
+
+ let g:ale_fixers.testft = ['AddDollars']
+
+ " We have to set the buftype to empty so the file will be written.
+ setlocal buftype=
+
+ call SetUpLinters()
+ call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
+
+ " We should save the file.
+ AssertEqual ['$a', '$b', '$c'], readfile(g:test_filename)
+ Assert !&modified, 'The file was marked as ''modified'''
+
+ if !has('win32')
+ " We should have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], ale#test#GetLoclistWithoutModule()
+ endif
+
+Expect(The buffer should be modified):
+ $a
+ $b
+ $c
+
Execute(ALEFix should not fix files on :wq):
let g:ale_fix_on_save = 1
let g:ale_lint_on_save = 1