mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Make ale_lint_on_save work with b:ale_fix_on_save = 1
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user