Set qflist/loclist window title properly ... (#588)
* Update list.vim Set qflist/loclist window title properly ... * Update list.vim 1. Remove redundant code. 2. Get absolute path from 'a:buffer'. * Set the list window titles appropriately for each version of Vim, and add tests
This commit is contained in:
parent
735a6a2a88
commit
81f27a99c8
2 changed files with 79 additions and 8 deletions
|
@ -12,18 +12,26 @@ function! ale#list#IsQuickfixOpen() abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#list#SetLists(buffer, loclist) abort
|
function! ale#list#SetLists(buffer, loclist) abort
|
||||||
|
let l:title = expand('#' . a:buffer . ':p')
|
||||||
|
|
||||||
if g:ale_set_quickfix
|
if g:ale_set_quickfix
|
||||||
call setqflist(a:loclist)
|
if has('nvim')
|
||||||
|
call setqflist(a:loclist, ' ', l:title)
|
||||||
|
else
|
||||||
|
call setqflist(a:loclist)
|
||||||
|
call setqflist([], 'r', {'title': l:title})
|
||||||
|
endif
|
||||||
elseif g:ale_set_loclist
|
elseif g:ale_set_loclist
|
||||||
" If windows support is off, bufwinid() may not exist.
|
" If windows support is off, bufwinid() may not exist.
|
||||||
if exists('*bufwinid')
|
" We'll set result in the current window, which might not be correct,
|
||||||
" Set the results on the window for the buffer.
|
" but is better than nothing.
|
||||||
call setloclist(bufwinid(str2nr(a:buffer)), a:loclist)
|
let l:win_id = exists('*bufwinid') ? bufwinid(str2nr(a:buffer)) : 0
|
||||||
|
|
||||||
|
if has('nvim')
|
||||||
|
call setloclist(l:win_id, a:loclist, ' ', l:title)
|
||||||
else
|
else
|
||||||
" Set the results in the current window.
|
call setloclist(l:win_id, a:loclist)
|
||||||
" This may not be the same window we ran the linters for, but
|
call setloclist(l:win_id, [], 'r', {'title': l:title})
|
||||||
" it's better than nothing.
|
|
||||||
call setloclist(0, a:loclist)
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
63
test/test_list_titles.vader
Normal file
63
test/test_list_titles.vader
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
Before:
|
||||||
|
Save g:ale_set_loclist
|
||||||
|
Save g:ale_set_quickfix
|
||||||
|
|
||||||
|
let g:ale_set_loclist = 0
|
||||||
|
let g:ale_set_quickfix = 0
|
||||||
|
|
||||||
|
silent! cd /testplugin/test
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call setloclist(0, [])
|
||||||
|
call setqflist([])
|
||||||
|
|
||||||
|
Execute(The loclist titles should be set appropriately):
|
||||||
|
silent noautocmd file foo
|
||||||
|
|
||||||
|
let g:ale_set_loclist = 1
|
||||||
|
|
||||||
|
call ale#list#SetLists(bufnr(''), [
|
||||||
|
\ {'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x', 'type': 'E'},
|
||||||
|
\])
|
||||||
|
|
||||||
|
AssertEqual [{
|
||||||
|
\ 'lnum': 5,
|
||||||
|
\ 'bufnr': bufnr(''),
|
||||||
|
\ 'col': 5,
|
||||||
|
\ 'text': 'x',
|
||||||
|
\ 'valid': 1,
|
||||||
|
\ 'vcol': 0,
|
||||||
|
\ 'nr': 0,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'pattern': '',
|
||||||
|
\}], getloclist(0)
|
||||||
|
|
||||||
|
if !has('nvim')
|
||||||
|
AssertEqual {'title': getcwd() . '/foo'}, getloclist(0, {'title': ''})
|
||||||
|
endif
|
||||||
|
|
||||||
|
Execute(The quickfix titles should be set appropriately):
|
||||||
|
silent noautocmd file foo
|
||||||
|
|
||||||
|
let g:ale_set_quickfix = 1
|
||||||
|
|
||||||
|
call ale#list#SetLists(bufnr(''), [
|
||||||
|
\ {'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x', 'type': 'E'},
|
||||||
|
\])
|
||||||
|
AssertEqual [{
|
||||||
|
\ 'lnum': 5,
|
||||||
|
\ 'bufnr': bufnr(''),
|
||||||
|
\ 'col': 5,
|
||||||
|
\ 'text': 'x',
|
||||||
|
\ 'valid': 1,
|
||||||
|
\ 'vcol': 0,
|
||||||
|
\ 'nr': 0,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'pattern': '',
|
||||||
|
\}], getqflist()
|
||||||
|
|
||||||
|
if !has('nvim')
|
||||||
|
AssertEqual {'title': getcwd() . '/foo'}, getqflist({'title': ''})
|
||||||
|
endif
|
Reference in a new issue