Merge pull request #1928 from felipesere/master
To avoid blocking build tools, suspend ALE when suspending vim
This commit is contained in:
commit
993f02ad80
@ -18,6 +18,22 @@ if !has_key(s:, 'executable_cache_map')
|
|||||||
let s:executable_cache_map = {}
|
let s:executable_cache_map = {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
function! ale#engine#CleanupEveryBuffer() abort
|
||||||
|
for l:key in keys(g:ale_buffer_info)
|
||||||
|
" The key could be a filename or a buffer number, so try and
|
||||||
|
" convert it to a number. We need a number for the other
|
||||||
|
" functions.
|
||||||
|
let l:buffer = str2nr(l:key)
|
||||||
|
|
||||||
|
if l:buffer > 0
|
||||||
|
" Stop all jobs and clear the results for everything, and delete
|
||||||
|
" all of the data we stored for the buffer.
|
||||||
|
call ale#engine#Cleanup(l:buffer)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale#engine#ResetExecutableCache() abort
|
function! ale#engine#ResetExecutableCache() abort
|
||||||
let s:executable_cache_map = {}
|
let s:executable_cache_map = {}
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -15,21 +15,6 @@ function! s:DisablePostamble() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CleanupEveryBuffer() abort
|
|
||||||
for l:key in keys(g:ale_buffer_info)
|
|
||||||
" The key could be a filename or a buffer number, so try and
|
|
||||||
" convert it to a number. We need a number for the other
|
|
||||||
" functions.
|
|
||||||
let l:buffer = str2nr(l:key)
|
|
||||||
|
|
||||||
if l:buffer > 0
|
|
||||||
" Stop all jobs and clear the results for everything, and delete
|
|
||||||
" all of the data we stored for the buffer.
|
|
||||||
call ale#engine#Cleanup(l:buffer)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ale#toggle#Toggle() abort
|
function! ale#toggle#Toggle() abort
|
||||||
let g:ale_enabled = !get(g:, 'ale_enabled')
|
let g:ale_enabled = !get(g:, 'ale_enabled')
|
||||||
|
|
||||||
@ -40,7 +25,7 @@ function! ale#toggle#Toggle() abort
|
|||||||
call ale#balloon#Enable()
|
call ale#balloon#Enable()
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call s:CleanupEveryBuffer()
|
call ale#engine#CleanupEveryBuffer()
|
||||||
call s:DisablePostamble()
|
call s:DisablePostamble()
|
||||||
|
|
||||||
if exists('*ale#balloon#Disable')
|
if exists('*ale#balloon#Disable')
|
||||||
@ -64,7 +49,7 @@ function! ale#toggle#Disable() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#toggle#Reset() abort
|
function! ale#toggle#Reset() abort
|
||||||
call s:CleanupEveryBuffer()
|
call ale#engine#CleanupEveryBuffer()
|
||||||
call ale#highlight#UpdateHighlights()
|
call ale#highlight#UpdateHighlights()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -224,4 +224,8 @@ augroup ALECleanupGroup
|
|||||||
" Clean up buffers automatically when they are unloaded.
|
" Clean up buffers automatically when they are unloaded.
|
||||||
autocmd BufDelete * if exists('*ale#engine#Cleanup') | call ale#engine#Cleanup(str2nr(expand('<abuf>'))) | endif
|
autocmd BufDelete * if exists('*ale#engine#Cleanup') | call ale#engine#Cleanup(str2nr(expand('<abuf>'))) | endif
|
||||||
autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand('<abuf>')))
|
autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand('<abuf>')))
|
||||||
|
|
||||||
|
if exists('##VimSuspend')
|
||||||
|
autocmd VimSuspend * if exists('*ale#engine#CleanupEveryBuffer') | call ale#engine#CleanupEveryBuffer() | endif
|
||||||
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
@ -175,10 +175,19 @@ Execute (g:ale_lint_on_filetype_changed = 1 should bind the FileType event):
|
|||||||
\ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''\v^FileType''')
|
\ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''\v^FileType''')
|
||||||
|
|
||||||
Execute (ALECleanupGroup should include the right commands):
|
Execute (ALECleanupGroup should include the right commands):
|
||||||
AssertEqual [
|
if exists('##VimSuspend')
|
||||||
\ 'BufDelete * if exists(''*ale#engine#Cleanup'') | call ale#engine#Cleanup(str2nr(expand(''<abuf>''))) | endif',
|
AssertEqual [
|
||||||
\ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
|
\ 'BufDelete * if exists(''*ale#engine#Cleanup'') | call ale#engine#Cleanup(str2nr(expand(''<abuf>''))) | endif',
|
||||||
\], CheckAutocmd('ALECleanupGroup')
|
\ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
|
||||||
|
\ 'VimSuspend * if exists(''*ale#engine#CleanupEveryBuffer'') | call ale#engine#CleanupEveryBuffer() | endif',
|
||||||
|
\], CheckAutocmd('ALECleanupGroup')
|
||||||
|
else
|
||||||
|
AssertEqual [
|
||||||
|
\ 'BufDelete * if exists(''*ale#engine#Cleanup'') | call ale#engine#Cleanup(str2nr(expand(''<abuf>''))) | endif',
|
||||||
|
\ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
|
||||||
|
\], CheckAutocmd('ALECleanupGroup')
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
Execute(Enabling completion should set up autocmd events correctly):
|
Execute(Enabling completion should set up autocmd events correctly):
|
||||||
let g:ale_completion_enabled = 0
|
let g:ale_completion_enabled = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user