Skip to content

Commit

Permalink
Fix #912 - Close lists automatically when g:ale_open_list is set to '…
Browse files Browse the repository at this point in the history
…on_save' again
  • Loading branch information
w0rp committed Sep 8, 2017
1 parent c6d3d64 commit b8dcdc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion autoload/ale/list.vim
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,19 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
" If ALE isn't currently checking for more problems, close the window if
" needed now. This check happens inside of this timer function, so
" the window can be closed reliably.
if !ale#engine#IsCheckingBuffer(bufnr(''))
if !ale#engine#IsCheckingBuffer(a:buffer)
call s:CloseWindowIfNeeded(a:buffer)
endif
endfunction

function! ale#list#SetLists(buffer, loclist) abort
if get(g:, 'ale_set_lists_synchronously') == 1
\|| getbufvar(a:buffer, 'ale_save_event_fired', 0)
" Update lists immediately if running a test synchronously, or if the
" buffer was saved.
"
" The lists need to be updated immediately when saving a buffer so
" that we can reliably close window automatically, if so configured.
call s:SetListsImpl(-1, a:buffer, a:loclist)
else
call ale#util#StartPartialTimer(
Expand Down
7 changes: 7 additions & 0 deletions test/test_list_opening.vader
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,19 @@ Execute(The ale_open_list='on_save' option should work):
" The list shouldn't open yet, the event wasn't fired.
Assert !ale#list#IsQuickfixOpen()

" Turn this option off, to ensure that we update lists immediately when we
" save buffers.
let g:ale_set_lists_synchronously = 0
let b:ale_save_event_fired = 1

call ale#list#SetLists(bufnr('%'), g:loclist)
" Now the list should have opened.
Assert ale#list#IsQuickfixOpen()

call ale#list#SetLists(bufnr('%'), [])
" The window should close again when the loclist is empty.
Assert !ale#list#IsQuickfixOpen()

Execute(The window shouldn't open on save when ale_open_list=0):
let b:ale_open_list = 0
let b:ale_save_event_fired = 1
Expand Down

0 comments on commit b8dcdc9

Please sign in to comment.