@@ -65,11 +65,6 @@ endfunction
65
65
66
66
function ! ale#highlight#UpdateHighlights () abort
67
67
let l: buffer = bufnr (' %' )
68
-
69
- if has_key (s: buffer_restore_map , l: buffer )
70
- call setmatches (s: buffer_restore_map [l: buffer ])
71
- endif
72
-
73
68
let l: has_new_items = has_key (s: buffer_highlights , l: buffer )
74
69
let l: loclist = l: has_new_items ? remove (s: buffer_highlights , l: buffer ) : []
75
70
@@ -80,7 +75,13 @@ function! ale#highlight#UpdateHighlights() abort
80
75
" Remove anything with a current match_id
81
76
call filter (l: loclist , ' !has_key(v:val, '' match_id'' )' )
82
77
83
- if l: has_new_items
78
+ " Restore items from the map of hidden items,
79
+ " if we don't have some new items to set already.
80
+ if empty (l: loclist ) && has_key (s: buffer_restore_map , l: buffer )
81
+ let l: loclist = s: buffer_restore_map [l: buffer ]
82
+ endif
83
+
84
+ if g: ale_enabled
84
85
for l: item in l: loclist
85
86
let l: col = l: item .col
86
87
let l: group = l: item .type == # ' E' ? ' ALEError' : ' ALEWarning'
@@ -96,12 +97,22 @@ function! ale#highlight#UpdateHighlights() abort
96
97
endfunction
97
98
98
99
function ! ale#highlight#BufferHidden (buffer ) abort
99
- " Remember all matches, so they can be restored later.
100
- let s: buffer_restore_map [a: buffer ] = filter (
101
- \ getmatches (),
102
- \ ' get(v:val, '' group'' , '''' )[:2] ==# '' ALE'' '
103
- \)
104
- call clearmatches ()
100
+ let l: info = get (g: ale_buffer_info , a: buffer , {' loclist' : []})
101
+ let l: loclist = deepcopy (l: info .loclist)
102
+
103
+ " Remember loclist items, so they can be restored later.
104
+ if ! empty (l: loclist )
105
+ " Remove match_ids, as they must be re-calculated when buffers are
106
+ " shown again.
107
+ for l: item in l: loclist
108
+ if has_key (l: item , ' match_id' )
109
+ call remove (l: item , ' match_id' )
110
+ endif
111
+ endfor
112
+
113
+ let s: buffer_restore_map [a: buffer ] = l: loclist
114
+ call clearmatches ()
115
+ endif
105
116
endfunction
106
117
107
118
augroup ALEHighlightBufferGroup
0 commit comments