Make ale_lint_on_save work with b:ale_fix_on_save = 1

This commit is contained in:
w0rp 2019-06-04 21:51:44 +01:00
parent 42a1fc2d29
commit 381fff0e4c
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 49 additions and 1 deletions

View File

@ -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

View File

@ -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