diff options
author | w0rp <devw0rp@gmail.com> | 2017-10-17 00:37:29 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-10-17 00:37:29 +0100 |
commit | 81d993086eae20cd8d2871b62e8889e54cfa9187 (patch) | |
tree | fbae675444608aa4fb354aa1aeecc7aa27b0f6cd /autoload | |
parent | 5946a128c30f24fdb69cb3ba59a55bc496b51a86 (diff) | |
download | ale-81d993086eae20cd8d2871b62e8889e54cfa9187.zip |
#904 - Allow linting to run on save a second after :q fails
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/events.vim | 11 | ||||
-rw-r--r-- | autoload/ale/fix.vim | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim index 1992b1ee..a7f6b378 100644 --- a/autoload/ale/events.vim +++ b/autoload/ale/events.vim @@ -2,21 +2,26 @@ function! ale#events#QuitEvent(buffer) abort " Remember when ALE is quitting for BufWrite, etc. - call setbufvar(a:buffer, 'ale_quitting', 1) + call setbufvar(a:buffer, 'ale_quitting', ale#util#ClockMilliseconds()) +endfunction + +function! ale#events#QuitRecently(buffer) abort + let l:time = getbufvar(a:buffer, 'ale_quitting', 0) + + return l:time && ale#util#ClockMilliseconds() - l:time < 1000 endfunction function! ale#events#SaveEvent(buffer) abort call setbufvar(a:buffer, 'ale_save_event_fired', 1) let l:should_lint = ale#Var(a:buffer, 'enabled') \ && g:ale_lint_on_save - \ && !getbufvar(a:buffer, 'ale_quitting') if g:ale_fix_on_save let l:will_fix = ale#fix#Fix('save_file') let l:should_lint = l:should_lint && !l:will_fix endif - if l:should_lint + if l:should_lint && !ale#events#QuitRecently(a:buffer) call ale#Queue(0, 'lint_file', a:buffer) endif endfunction diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index 2b5387de..a9bb7d48 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -58,7 +58,7 @@ function! ale#fix#ApplyQueuedFixes() abort " fixing problems. if g:ale_enabled \&& l:should_lint - \&& !getbufvar(l:buffer, 'ale_quitting') + \&& !ale#events#QuitRecently(l:buffer) call ale#Queue(0, l:data.should_save ? 'lint_file' : '') endif endfunction |