mirror of https://github.com/dense-analysis/ale
Fix #2497 - ALE should not lint on save when disabled after fixing
This commit is contained in:
parent
bf17bbf898
commit
42cbff29f8
|
@ -42,6 +42,7 @@ function! ale#fix#ApplyQueuedFixes() abort
|
||||||
|
|
||||||
if l:data.should_save
|
if l:data.should_save
|
||||||
let l:should_lint = g:ale_fix_on_save
|
let l:should_lint = g:ale_fix_on_save
|
||||||
|
\ && ale#Var(l:buffer, 'lint_on_save')
|
||||||
else
|
else
|
||||||
let l:should_lint = l:data.changes_made
|
let l:should_lint = l:data.changes_made
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -8,6 +8,7 @@ Before:
|
||||||
|
|
||||||
silent! cd /testplugin/test/fix
|
silent! cd /testplugin/test/fix
|
||||||
|
|
||||||
|
unlet! b:ale_lint_on_save
|
||||||
let g:ale_enabled = 0
|
let g:ale_enabled = 0
|
||||||
let g:ale_echo_cursor = 0
|
let g:ale_echo_cursor = 0
|
||||||
let g:ale_run_synchronously = 1
|
let g:ale_run_synchronously = 1
|
||||||
|
@ -191,6 +192,7 @@ After:
|
||||||
unlet! g:ale_run_synchronously_callbacks
|
unlet! g:ale_run_synchronously_callbacks
|
||||||
unlet! g:ale_emulate_job_failure
|
unlet! g:ale_emulate_job_failure
|
||||||
unlet! b:ale_fixers
|
unlet! b:ale_fixers
|
||||||
|
unlet! b:ale_lint_on_save
|
||||||
unlet! b:ale_fix_on_save
|
unlet! b:ale_fix_on_save
|
||||||
unlet! b:ale_quitting
|
unlet! b:ale_quitting
|
||||||
delfunction AddCarets
|
delfunction AddCarets
|
||||||
|
@ -631,6 +633,52 @@ Expect(The buffer should be the same):
|
||||||
b
|
b
|
||||||
c
|
c
|
||||||
|
|
||||||
|
Execute(ALEFix should not lint the buffer on save if linting on save is disabled globally):
|
||||||
|
let g:ale_fix_on_save = 1
|
||||||
|
let g:ale_lint_on_save = 0
|
||||||
|
let g:ale_enabled = 1
|
||||||
|
|
||||||
|
let g:test_filename = tempname()
|
||||||
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
||||||
|
|
||||||
|
let g:ale_fixers.testft = ['DoNothing']
|
||||||
|
|
||||||
|
call SetUpLinters()
|
||||||
|
call ale#events#SaveEvent(bufnr(''))
|
||||||
|
call ale#test#FlushJobs()
|
||||||
|
|
||||||
|
Assert !filereadable(g:test_filename), 'The file should not have been saved'
|
||||||
|
|
||||||
|
AssertEqual [], ale#test#GetLoclistWithoutModule()
|
||||||
|
|
||||||
|
Expect(The buffer should be the same):
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
|
||||||
|
Execute(ALEFix should not lint the buffer on save if linting on save is disabled locally):
|
||||||
|
let g:ale_fix_on_save = 1
|
||||||
|
let b:ale_lint_on_save = 0
|
||||||
|
let g:ale_enabled = 1
|
||||||
|
|
||||||
|
let g:test_filename = tempname()
|
||||||
|
execute 'noautocmd silent file ' . fnameescape(g:test_filename)
|
||||||
|
|
||||||
|
let g:ale_fixers.testft = ['DoNothing']
|
||||||
|
|
||||||
|
call SetUpLinters()
|
||||||
|
call ale#events#SaveEvent(bufnr(''))
|
||||||
|
call ale#test#FlushJobs()
|
||||||
|
|
||||||
|
Assert !filereadable(g:test_filename), 'The file should not have been saved'
|
||||||
|
|
||||||
|
AssertEqual [], ale#test#GetLoclistWithoutModule()
|
||||||
|
|
||||||
|
Expect(The buffer should be the same):
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
|
||||||
Given testft (A file with three lines):
|
Given testft (A file with three lines):
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
|
|
|
@ -86,7 +86,7 @@ Execute(No linting should be for :w after :q fails):
|
||||||
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
|
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
|
||||||
|
|
||||||
Execute(No linting should be done on :wq or :x after fixing files):
|
Execute(No linting should be done on :wq or :x after fixing files):
|
||||||
let g:ale_lint_on_save = 0
|
let g:ale_lint_on_save = 1
|
||||||
let g:ale_fix_on_save = 1
|
let g:ale_fix_on_save = 1
|
||||||
|
|
||||||
call ale#events#SaveEvent(bufnr(''))
|
call ale#events#SaveEvent(bufnr(''))
|
||||||
|
@ -103,7 +103,7 @@ Execute(No linting should be done on :wq or :x after fixing files):
|
||||||
AssertEqual [], ale#test#GetLoclistWithoutModule()
|
AssertEqual [], ale#test#GetLoclistWithoutModule()
|
||||||
|
|
||||||
Execute(Linting should be done after :q fails and fixing files):
|
Execute(Linting should be done after :q fails and fixing files):
|
||||||
let g:ale_lint_on_save = 0
|
let g:ale_lint_on_save = 1
|
||||||
let g:ale_fix_on_save = 1
|
let g:ale_fix_on_save = 1
|
||||||
|
|
||||||
call ale#events#QuitEvent(bufnr(''))
|
call ale#events#QuitEvent(bufnr(''))
|
||||||
|
|
Loading…
Reference in New Issue