From f74e22b938798a6bd64e6fa55754c3e7e28285dd Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 19 Dec 2017 15:35:57 +0000 Subject: Clean up ALE linter buffer data when buffers are deleted, not unloaded --- plugin/ale.vim | 2 +- test/test_autocmd_commands.vader | 2 +- test/test_cleanup.vader | 23 +++++++++++------------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugin/ale.vim b/plugin/ale.vim index a07915f7..2f613b53 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -285,7 +285,7 @@ call ale#toggle#InitAuGroups() augroup ALECleanupGroup autocmd! " Clean up buffers automatically when they are unloaded. - autocmd BufUnload * call ale#engine#Cleanup(str2nr(expand(''))) + autocmd BufDelete * call ale#engine#Cleanup(str2nr(expand(''))) autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand(''))) augroup END diff --git a/test/test_autocmd_commands.vader b/test/test_autocmd_commands.vader index e7e9e86e..c03e8fb7 100644 --- a/test/test_autocmd_commands.vader +++ b/test/test_autocmd_commands.vader @@ -191,7 +191,7 @@ Execute (g:ale_echo_cursor = 1 should bind cursor events): Execute (ALECleanupGroup should include the right commands): AssertEqual [ - \ 'BufUnload * call ale#engine#Cleanup(str2nr(expand('''')))', + \ 'BufDelete * call ale#engine#Cleanup(str2nr(expand('''')))', \ 'QuitPre * call ale#events#QuitEvent(str2nr(expand('''')))', \], CheckAutocmd('ALECleanupGroup') diff --git a/test/test_cleanup.vader b/test/test_cleanup.vader index 23e5bcf0..232874aa 100644 --- a/test/test_cleanup.vader +++ b/test/test_cleanup.vader @@ -1,15 +1,14 @@ -Before: - let g:buffer = bufnr('%') +After: + unlet! g:buffer + let g:ale_buffer_info = {} - let g:ale_buffer_info = { - \ g:buffer : {'temporary_file_list': [], 'temporary_directory_list': []}, - \ 10347: {'temporary_file_list': [], 'temporary_directory_list': []}, - \} +Execute('ALE globals should be cleared when the buffer is deleted): + new -After: - unlet! g:buffer - let g:ale_buffer_info = {} + let g:ale_buffer_info = { + \ bufnr(''): {'temporary_file_list': [], 'temporary_directory_list': []}, + \ 10347: {'temporary_file_list': [], 'temporary_directory_list': []}, + \} -Execute('ALE globals should be cleared when the buffer is closed.'): - :q! - AssertEqual {10347: {'temporary_file_list': [], 'temporary_directory_list': []}}, g:ale_buffer_info + bdelete + AssertEqual {10347: {'temporary_file_list': [], 'temporary_directory_list': []}}, g:ale_buffer_info -- cgit v1.2.3