Clean up ALE linter buffer data when buffers are deleted, not unloaded

This commit is contained in:
w0rp 2017-12-19 15:35:57 +00:00
parent d2bea5c310
commit f74e22b938
3 changed files with 14 additions and 15 deletions

View file

@ -285,7 +285,7 @@ call ale#toggle#InitAuGroups()
augroup ALECleanupGroup augroup ALECleanupGroup
autocmd! autocmd!
" Clean up buffers automatically when they are unloaded. " Clean up buffers automatically when they are unloaded.
autocmd BufUnload * call ale#engine#Cleanup(str2nr(expand('<abuf>'))) autocmd BufDelete * call ale#engine#Cleanup(str2nr(expand('<abuf>')))
autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand('<abuf>'))) autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand('<abuf>')))
augroup END augroup END

View file

@ -191,7 +191,7 @@ Execute (g:ale_echo_cursor = 1 should bind cursor events):
Execute (ALECleanupGroup should include the right commands): Execute (ALECleanupGroup should include the right commands):
AssertEqual [ AssertEqual [
\ 'BufUnload * call ale#engine#Cleanup(str2nr(expand(''<abuf>'')))', \ 'BufDelete * call ale#engine#Cleanup(str2nr(expand(''<abuf>'')))',
\ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))', \ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
\], CheckAutocmd('ALECleanupGroup') \], CheckAutocmd('ALECleanupGroup')

View file

@ -1,15 +1,14 @@
Before:
let g:buffer = bufnr('%')
let g:ale_buffer_info = {
\ g:buffer : {'temporary_file_list': [], 'temporary_directory_list': []},
\ 10347: {'temporary_file_list': [], 'temporary_directory_list': []},
\}
After: After:
unlet! g:buffer unlet! g:buffer
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
Execute('ALE globals should be cleared when the buffer is closed.'): Execute('ALE globals should be cleared when the buffer is deleted):
:q! new
AssertEqual {10347: {'temporary_file_list': [], 'temporary_directory_list': []}}, g:ale_buffer_info
let g:ale_buffer_info = {
\ bufnr(''): {'temporary_file_list': [], 'temporary_directory_list': []},
\ 10347: {'temporary_file_list': [], 'temporary_directory_list': []},
\}
bdelete
AssertEqual {10347: {'temporary_file_list': [], 'temporary_directory_list': []}}, g:ale_buffer_info