diff options
author | w0rp <devw0rp@gmail.com> | 2017-03-12 22:46:33 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-03-12 22:46:33 +0000 |
commit | 711ab9936274608dad48b20b58727c416672c115 (patch) | |
tree | 02657ac97ed3d2b6618abe8080056a8d4865e502 /autoload | |
parent | 382e569f668f7d7f1e21ff705a124cad54dabef1 (diff) | |
download | ale-711ab9936274608dad48b20b58727c416672c115.zip |
#333 Remember the IDs for highlights
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/highlight.vim | 19 | ||||
-rw-r--r-- | autoload/ale/sign.vim | 3 |
2 files changed, 15 insertions, 7 deletions
diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim index 1669ebd2..54103aa9 100644 --- a/autoload/ale/highlight.vim +++ b/autoload/ale/highlight.vim @@ -22,12 +22,16 @@ function! ale#highlight#UnqueueHighlights(buffer) abort endif endfunction -function! s:RemoveOldHighlights() abort +function! s:GetALEMatches() abort + let l:list = [] + for l:match in getmatches() if l:match['group'] ==# 'ALEError' || l:match['group'] ==# 'ALEWarning' - call matchdelete(l:match['id']) + call add(l:list, l:match) endif endfor + + return l:list endfunction function! ale#highlight#UpdateHighlights() abort @@ -36,7 +40,9 @@ function! ale#highlight#UpdateHighlights() abort let l:loclist = l:has_new_items ? remove(s:buffer_highlights, l:buffer) : [] if l:has_new_items || !g:ale_enabled - call s:RemoveOldHighlights() + for l:match in s:GetALEMatches() + call matchdelete(l:match['id']) + endfor endif if l:has_new_items @@ -46,7 +52,10 @@ function! ale#highlight#UpdateHighlights() abort let l:line = l:item.lnum let l:size = 1 - call matchaddpos(l:group, [[l:line, l:col, l:size]]) + " Rememeber the match ID for the item. + " This ID will be used to preserve loclist items which are set + " many times. + let l:item.match_id = matchaddpos(l:group, [[l:line, l:col, l:size]]) endfor endif endfunction @@ -64,7 +73,7 @@ function! ale#highlight#SetHighlights(buffer, loclist) abort " " We'll filter the loclist down to items we can set now. let s:buffer_highlights[a:buffer] = filter( - \ deepcopy(a:loclist), + \ copy(a:loclist), \ 'v:val.bufnr == a:buffer && v:val.col > 0' \) diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim index 1a39ba89..fc12e158 100644 --- a/autoload/ale/sign.vim +++ b/autoload/ale/sign.vim @@ -125,8 +125,7 @@ function! ale#sign#SetSigns(buffer, loclist) abort \ : 'ALEWarningSign' " Save the sign IDs we are setting back on our loclist objects. - " These IDs can be used later for changing line numbers of items - " we keep, based on what Vim adjusts automatically. + " These IDs will be used to preserve items which are set many times. for l:obj in l:sublist let l:obj.sign_id = l:sign_id endfor |