@@ -172,23 +172,28 @@ else
172
172
function ! s: HighlightEOLWhitespace ()
173
173
call <SID> ClearHighlighting ()
174
174
if <SID> ShouldHighlight ()
175
- let s: match_id = matchadd (' ExtraWhitespace' , s: eol_whitespace_pattern , 10 , get (s: , ' match_id' , -1 ))
175
+ let w: better_whitespace_match_id = matchadd (' ExtraWhitespace' ,
176
+ \ s: eol_whitespace_pattern , 10 , get (w: , ' better_whitespace_match_id' , -1 ))
176
177
endif
177
178
endfunction
178
179
179
180
" Match Whitespace on all lines except the current one
180
181
function ! s: HighlightEOLWhitespaceExceptCurrentLine ()
181
182
call <SID> ClearHighlighting ()
182
183
if <SID> ShouldHighlight ()
183
- let s: match_id = matchadd (' ExtraWhitespace' ,
184
+ let w: better_whitespace_match_id = matchadd (' ExtraWhitespace' ,
184
185
\ ' \%<' . line (' .' ) . ' l' . s: eol_whitespace_pattern .
185
- \ ' \|\%>' . line (' .' ) . ' l' . s: eol_whitespace_pattern , 10 , get (s : , ' match_id ' , -1 ))
186
+ \ ' \|\%>' . line (' .' ) . ' l' . s: eol_whitespace_pattern , 10 , get (w : , ' better_whitespace_match_id ' , -1 ))
186
187
endif
187
188
endfunction
188
189
189
190
" Remove Whitespace matching
190
191
function ! s: ClearHighlighting ()
191
- silent ! call matchdelete (get (s: , ' match_id' , -1 ))
192
+ let match_id = get (w: , ' better_whitespace_match_id' , -1 )
193
+ let valid_ids = map (getmatches (), ' v:val["id"]' )
194
+ if match_id >= 0 && index (valid_ids, match_id) >= 0
195
+ call matchdelete (match_id)
196
+ endif
192
197
endfunction
193
198
endif
194
199
@@ -382,6 +387,13 @@ endfunction
382
387
autocmd FileType ,WinEnter ,BufWinEnter * call <SID> SetupAutoCommands ()
383
388
autocmd ColorScheme * call <SID> WhitespaceInit ()
384
389
390
+ " Also check on specific buftype changes
391
+ if has (' nvim' )
392
+ autocmd TermOpen * call <SID> SetupAutoCommands ()
393
+ else
394
+ autocmd TerminalWinOpen * call <SID> SetupAutoCommands ()
395
+ endif
396
+
385
397
386
398
" Section: Setting of per-buffer higlighting/stripping
387
399
0 commit comments