Skip to content

Commit

Permalink
Deduplicate items in location list (#3792)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpanders authored Jul 3, 2021
1 parent 7862633 commit 49bdbc3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions autoload/ale/list.vim
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,23 @@ function! s:ShouldOpen(buffer) abort
return l:val is 1 || (l:val is# 'on_save' && l:saved)
endfunction

function! s:Deduplicate(list) abort
let l:list = a:list

call sort(l:list, function('ale#util#LocItemCompareWithText'))
call uniq(l:list, function('ale#util#LocItemCompareWithText'))

return l:list
endfunction

function! ale#list#GetCombinedList() abort
let l:list = []

for l:info in values(g:ale_buffer_info)
call extend(l:list, l:info.loclist)
endfor

call sort(l:list, function('ale#util#LocItemCompareWithText'))
call uniq(l:list, function('ale#util#LocItemCompareWithText'))

return l:list
return s:Deduplicate(l:list)
endfunction

function! s:FixList(buffer, list) abort
Expand Down Expand Up @@ -99,11 +105,13 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
" but it's better than nothing.
let l:ids = s:WinFindBuf(a:buffer)

let l:loclist = s:Deduplicate(a:loclist)

for l:id in l:ids
if has('nvim')
call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title)
call setloclist(l:id, s:FixList(a:buffer, l:loclist), ' ', l:title)
else
call setloclist(l:id, s:FixList(a:buffer, a:loclist))
call setloclist(l:id, s:FixList(a:buffer, l:loclist))
call setloclist(l:id, [], 'r', {'title': l:title})
endif
endfor
Expand Down

0 comments on commit 49bdbc3

Please sign in to comment.