diff options
author | Gregory Anders <greg@gpanders.com> | 2021-07-03 03:38:37 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-03 18:38:37 +0900 |
commit | 49bdbc3ba5c157c0bef9ee8553f232f073479bb8 (patch) | |
tree | 97614648f2b5d1e275ea3cab7d1c9ec238da8ac0 /autoload | |
parent | 7862633d9d0e35157d54ad1487bd5a73c618fc7f (diff) | |
download | ale-49bdbc3ba5c157c0bef9ee8553f232f073479bb8.zip |
Deduplicate items in location list (#3792)
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/list.vim | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim index c2ae5cc5..089aa2c0 100644 --- a/autoload/ale/list.vim +++ b/autoload/ale/list.vim @@ -44,6 +44,15 @@ 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 = [] @@ -51,10 +60,7 @@ function! ale#list#GetCombinedList() abort 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 @@ -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 |