Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate items in location list #3792

Merged
merged 1 commit into from
Jul 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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