Merge pull request #2253 from jj-kim/master

Improve location list behavior on split windows of same buffer.
This commit is contained in:
w0rp 2019-06-08 23:25:02 +01:00 committed by GitHub
commit 59829bc194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 14 deletions

View File

@ -71,8 +71,8 @@ function! s:FixList(buffer, list) abort
return l:new_list return l:new_list
endfunction endfunction
function! s:BufWinId(buffer) abort function! s:WinFindBuf(buffer) abort
return exists('*bufwinid') ? bufwinid(str2nr(a:buffer)) : 0 return exists('*win_findbuf') ? win_findbuf(str2nr(a:buffer)) : [0]
endfunction endfunction
function! s:SetListsImpl(timer_id, buffer, loclist) abort 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}) call setqflist([], 'r', {'title': l:title})
endif 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, win_findbuf() may not exist.
" We'll set result in the current window, which might not be correct, " We'll set result in the current window, which might not be correct,
" but it's better than nothing. " but it's better than nothing.
let l:id = s:BufWinId(a:buffer) let l:ids = s:WinFindBuf(a:buffer)
if has('nvim') for l:id in l:ids
call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title) if has('nvim')
else call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title)
call setloclist(l:id, s:FixList(a:buffer, a:loclist)) else
call setloclist(l:id, [], 'r', {'title': l:title}) call setloclist(l:id, s:FixList(a:buffer, a:loclist))
endif call setloclist(l:id, [], 'r', {'title': l:title})
endif
endfor
endif endif
" Open a window to show the problems if we need to. " Open a window to show the problems if we need to.
@ -181,11 +183,13 @@ function! s:CloseWindowIfNeeded(buffer) abort
cclose cclose
endif endif
else 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)) for l:win_id in l:win_ids
lclose if g:ale_set_loclist && empty(getloclist(l:win_id))
endif lclose
endif
endfor
endif endif
" Ignore 'Cannot close last window' errors. " Ignore 'Cannot close last window' errors.
catch /E444/ catch /E444/