2017-01-22 08:33:16 -05:00
|
|
|
" Author: Yann Fery <yann@fery.me>
|
|
|
|
Before:
|
2017-06-01 05:39:21 -04:00
|
|
|
Save g:ale_set_loclist
|
|
|
|
Save g:ale_set_quickfix
|
|
|
|
Save g:ale_open_list
|
|
|
|
Save g:ale_keep_list_window_open
|
|
|
|
Save g:ale_list_window_size
|
2017-08-19 09:28:51 -04:00
|
|
|
Save g:ale_buffer_info
|
2017-06-01 05:39:21 -04:00
|
|
|
|
|
|
|
let g:ale_set_loclist = 1
|
|
|
|
let g:ale_set_quickfix = 0
|
|
|
|
let g:ale_open_list = 0
|
|
|
|
let g:ale_keep_list_window_open = 0
|
|
|
|
let g:ale_list_window_size = 10
|
|
|
|
|
2017-01-22 08:33:16 -05:00
|
|
|
let g:loclist = [
|
2017-08-19 09:28:51 -04:00
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 5, 'col': 4, 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 10, 'text': 'x'},
|
|
|
|
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 2, 'text': 'x'},
|
2017-01-22 08:33:16 -05:00
|
|
|
\]
|
2017-08-19 09:28:51 -04:00
|
|
|
let g:ale_buffer_info = {bufnr(''): {'loclist': g:loclist}}
|
2017-01-22 08:33:16 -05:00
|
|
|
|
2017-06-01 05:39:21 -04:00
|
|
|
function GetQuickfixHeight() abort
|
|
|
|
for l:win in range(1, winnr('$'))
|
|
|
|
if getwinvar(l:win, '&buftype') ==# 'quickfix'
|
|
|
|
return winheight(l:win)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return 0
|
|
|
|
endfunction
|
|
|
|
|
2017-01-22 08:33:16 -05:00
|
|
|
After:
|
2017-06-01 05:39:21 -04:00
|
|
|
Restore
|
|
|
|
|
|
|
|
unlet! g:loclist
|
|
|
|
unlet! b:ale_list_window_size
|
2017-08-07 19:46:42 -04:00
|
|
|
unlet! b:ale_open_list
|
|
|
|
unlet! b:ale_keep_list_window_open
|
|
|
|
unlet! b:ale_save_event_fired
|
|
|
|
|
2017-06-01 05:39:21 -04:00
|
|
|
delfunction GetQuickfixHeight
|
|
|
|
|
2017-01-22 08:33:16 -05:00
|
|
|
" Close quickfix window after every execute block
|
|
|
|
lcl
|
|
|
|
ccl
|
|
|
|
call setloclist(0, [])
|
|
|
|
call setqflist([])
|
|
|
|
|
|
|
|
Execute(IsQuickfixOpen should return the right output):
|
|
|
|
AssertEqual 0, ale#list#IsQuickfixOpen()
|
|
|
|
call setloclist(0, g:loclist)
|
|
|
|
lopen
|
|
|
|
AssertEqual 1, ale#list#IsQuickfixOpen()
|
|
|
|
lcl
|
|
|
|
AssertEqual 0, ale#list#IsQuickfixOpen()
|
|
|
|
call setqflist(g:loclist)
|
|
|
|
copen
|
|
|
|
AssertEqual 1, ale#list#IsQuickfixOpen()
|
|
|
|
ccl
|
|
|
|
AssertEqual 0, ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
Execute(The quickfix window should not open by default for the loclist):
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-01-22 08:33:16 -05:00
|
|
|
Assert !ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
Execute(The quickfix window should open for just the loclist):
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
|
|
|
|
" It should not open for an empty list.
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-01-22 08:33:16 -05:00
|
|
|
Assert !ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
" With a non-empty loclist, the window must open.
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-01-22 08:33:16 -05:00
|
|
|
Assert ale#list#IsQuickfixOpen()
|
|
|
|
|
2017-03-23 18:03:01 -04:00
|
|
|
" Clear the list and it should close again.
|
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-03-23 18:03:01 -04:00
|
|
|
Assert !ale#list#IsQuickfixOpen()
|
|
|
|
|
2017-06-01 05:39:21 -04:00
|
|
|
Execute(The quickfix window height should be correct for the loclist):
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
let g:ale_list_window_size = 7
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-06-01 05:39:21 -04:00
|
|
|
|
|
|
|
AssertEqual 7, GetQuickfixHeight()
|
|
|
|
|
|
|
|
Execute(The quickfix window height should be correct for the loclist with buffer variables):
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
let b:ale_list_window_size = 8
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-06-01 05:39:21 -04:00
|
|
|
|
|
|
|
AssertEqual 8, GetQuickfixHeight()
|
|
|
|
|
2017-01-22 08:33:16 -05:00
|
|
|
Execute(The quickfix window should stay open for just the loclist):
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
let g:ale_keep_list_window_open = 1
|
|
|
|
|
|
|
|
" The window should stay open after even after it is made blank again.
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-01-22 08:33:16 -05:00
|
|
|
Assert ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
Execute(The quickfix window should not open by default when quickfix is on):
|
|
|
|
let g:ale_set_quickfix = 1
|
|
|
|
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-01-22 08:33:16 -05:00
|
|
|
Assert !ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
Execute(The quickfix window should open for the quickfix list):
|
|
|
|
let g:ale_set_quickfix = 1
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
|
2017-08-19 09:28:51 -04:00
|
|
|
let g:ale_buffer_info[bufnr('') + 1] = {
|
|
|
|
\ 'loclist': [{'bufnr': -1, 'filename': '/foo/bar', 'lnum': 5, 'col': 5, 'text': 'x'}],
|
|
|
|
\}
|
|
|
|
|
2017-01-22 08:33:16 -05:00
|
|
|
" It should not open for an empty list.
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
|
|
|
Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was opened when the list was empty'
|
2017-01-22 08:33:16 -05:00
|
|
|
|
|
|
|
" With a non-empty quickfix list, the window must open.
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
|
|
|
Assert ale#list#IsQuickfixOpen(), 'The quickfix window was closed when the list was not empty'
|
2017-01-22 08:33:16 -05:00
|
|
|
|
2017-08-19 09:28:51 -04:00
|
|
|
" Clear this List. The window should stay open, as there are other items.
|
|
|
|
let g:ale_buffer_info[bufnr('')].loclist = []
|
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
|
|
|
Assert ale#list#IsQuickfixOpen(), 'The quickfix window closed even though there are items in another buffer'
|
|
|
|
|
|
|
|
" Clear the other List now. Now the window should close.
|
|
|
|
call remove(g:ale_buffer_info, bufnr('') + 1)
|
2017-03-23 18:03:01 -04:00
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-08-19 09:28:51 -04:00
|
|
|
Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was not closed'
|
2017-03-23 18:03:01 -04:00
|
|
|
|
2017-01-22 08:33:16 -05:00
|
|
|
Execute(The quickfix window should stay open for the quickfix list):
|
|
|
|
let g:ale_set_quickfix = 1
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
let g:ale_keep_list_window_open = 1
|
|
|
|
|
|
|
|
" The window should stay open after even after it is made blank again.
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-03-08 19:43:53 -05:00
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-01-22 08:33:16 -05:00
|
|
|
Assert ale#list#IsQuickfixOpen()
|
2017-06-01 05:39:21 -04:00
|
|
|
|
|
|
|
Execute(The quickfix window height should be correct for the quickfix list):
|
|
|
|
let g:ale_set_quickfix = 1
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
let g:ale_list_window_size = 7
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-06-01 05:39:21 -04:00
|
|
|
|
|
|
|
AssertEqual 7, GetQuickfixHeight()
|
|
|
|
|
|
|
|
Execute(The quickfix window height should be correct for the quickfix list with buffer variables):
|
|
|
|
let g:ale_set_quickfix = 1
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
let b:ale_list_window_size = 8
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
2017-06-07 18:12:45 -04:00
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
2017-06-01 05:39:21 -04:00
|
|
|
|
|
|
|
AssertEqual 8, GetQuickfixHeight()
|
2017-08-07 19:46:42 -04:00
|
|
|
|
|
|
|
Execute(The buffer ale_open_list option should be respected):
|
|
|
|
let b:ale_open_list = 1
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
|
|
|
Assert ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
Execute(The buffer ale_keep_list_window_open option should be respected):
|
|
|
|
let b:ale_open_list = 1
|
|
|
|
let b:ale_keep_list_window_open = 1
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
|
|
|
call ale#list#SetLists(bufnr('%'), [])
|
|
|
|
call ale#list#CloseWindowIfNeeded(bufnr(''))
|
|
|
|
|
|
|
|
Assert ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
Execute(The ale_open_list='on_save' option should work):
|
|
|
|
let b:ale_open_list = 'on_save'
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
|
|
|
" The list shouldn't open yet, the event wasn't fired.
|
|
|
|
Assert !ale#list#IsQuickfixOpen()
|
|
|
|
|
|
|
|
let b:ale_save_event_fired = 1
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
|
|
|
" Now the list should have opened.
|
|
|
|
Assert ale#list#IsQuickfixOpen()
|
2017-08-08 02:29:10 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
call ale#list#SetLists(bufnr('%'), g:loclist)
|
|
|
|
" Now the list should have opened.
|
|
|
|
Assert !ale#list#IsQuickfixOpen()
|