Skip to content

Commit 51857e2

Browse files
committed
Reset ExtraWhitspace highlight group if cleared by a colorscheme change
Fix #28
1 parent bf6d1ec commit 51857e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

plugin/better-whitespace.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endfunction
6161
" Ensure the 'ExtraWhitespace' highlight group has been defined
6262
function! s:WhitespaceInit()
6363
" Check if the user has already defined highlighting for this group
64-
if hlexists("ExtraWhitespace") == 0
64+
if hlexists("ExtraWhitespace") == 0 || synIDattr(synIDtrans(hlID("ExtraWhitespace")), "bg") == -1
6565
highlight ExtraWhitespace ctermbg = red guibg = #FF0000
6666
endif
6767
let s:better_whitespace_initialized = 1
@@ -185,6 +185,7 @@ command! CurrentLineWhitespaceOn call <SID>CurrentLineWhitespaceOn()
185185

186186
" Process auto commands upon load
187187
autocmd VimEnter,WinEnter,BufEnter,FileType * call <SID>SetupAutoCommands()
188+
autocmd ColorScheme * call <SID>WhitespaceInit()
188189

189190
" Executes all auto commands
190191
function! <SID>SetupAutoCommands()

0 commit comments

Comments
 (0)