Merge pull request #2253 from jj-kim/master
Improve location list behavior on split windows of same buffer.
This commit is contained in:
commit
59829bc194
1 changed files with 18 additions and 14 deletions
|
@ -71,8 +71,8 @@ function! s:FixList(buffer, list) abort
|
|||
return l:new_list
|
||||
endfunction
|
||||
|
||||
function! s:BufWinId(buffer) abort
|
||||
return exists('*bufwinid') ? bufwinid(str2nr(a:buffer)) : 0
|
||||
function! s:WinFindBuf(buffer) abort
|
||||
return exists('*win_findbuf') ? win_findbuf(str2nr(a:buffer)) : [0]
|
||||
endfunction
|
||||
|
||||
function! s:SetListsImpl(timer_id, buffer, loclist) abort
|
||||
|
@ -88,17 +88,19 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
|
|||
call setqflist([], 'r', {'title': l:title})
|
||||
endif
|
||||
elseif g:ale_set_loclist
|
||||
" If windows support is off, bufwinid() may not exist.
|
||||
" If windows support is off, win_findbuf() may not exist.
|
||||
" We'll set result in the current window, which might not be correct,
|
||||
" but it's better than nothing.
|
||||
let l:id = s:BufWinId(a:buffer)
|
||||
let l:ids = s:WinFindBuf(a:buffer)
|
||||
|
||||
if has('nvim')
|
||||
call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title)
|
||||
else
|
||||
call setloclist(l:id, s:FixList(a:buffer, a:loclist))
|
||||
call setloclist(l:id, [], 'r', {'title': l:title})
|
||||
endif
|
||||
for l:id in l:ids
|
||||
if has('nvim')
|
||||
call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title)
|
||||
else
|
||||
call setloclist(l:id, s:FixList(a:buffer, a:loclist))
|
||||
call setloclist(l:id, [], 'r', {'title': l:title})
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Open a window to show the problems if we need to.
|
||||
|
@ -181,11 +183,13 @@ function! s:CloseWindowIfNeeded(buffer) abort
|
|||
cclose
|
||||
endif
|
||||
else
|
||||
let l:win_id = s:BufWinId(a:buffer)
|
||||
let l:win_ids = s:WinFindBuf(a:buffer)
|
||||
|
||||
if g:ale_set_loclist && empty(getloclist(l:win_id))
|
||||
lclose
|
||||
endif
|
||||
for l:win_id in l:win_ids
|
||||
if g:ale_set_loclist && empty(getloclist(l:win_id))
|
||||
lclose
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
" Ignore 'Cannot close last window' errors.
|
||||
catch /E444/
|
||||
|
|
Reference in a new issue