diff options
author | Jason Kim <jj_kim@berkeley.edu> | 2019-01-16 16:38:06 -0800 |
---|---|---|
committer | Jason Kim <jj_kim@berkeley.edu> | 2019-01-16 17:15:47 -0800 |
commit | 8b0879212f8771f79cd3233e8a4f829c93d05915 (patch) | |
tree | 0986a8efa5cb881e2b677ffd208410a2eaca033e | |
parent | d1fc084b2d3af6dd9807a01a6ca7822af6c2a78f (diff) | |
download | ale-8b0879212f8771f79cd3233e8a4f829c93d05915.zip |
Improve location list behavior on split windows of same buffer.
-rw-r--r-- | autoload/ale/list.vim | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim index 3417575c..1ba7d4da 100644 --- a/autoload/ale/list.vim +++ b/autoload/ale/list.vim @@ -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) - - 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 + let l:ids = s:WinFindBuf(a:buffer) + + 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/ |