Skip to content

Commit

Permalink
Fix bug with highlighting in NerdTree windows
Browse files Browse the repository at this point in the history
Editing a directory (and allowing NerdTree to intercept it) causes the
`BufWinEnter` autocmd to not fire, use `BufEnter` instead.

Clear `w:lsc_highlights_version` when clearing highlights, otherwise
re-entering a buffer with highlights will think it's fresh.
  • Loading branch information
natebosch committed Mar 10, 2018
1 parent 2c7ef39 commit 8ea0d66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

- Add `:LSClientDocumentSymbol` command to populate the quickfix list with
symbols in the current document.
- Bug Fix: Clear highlighting when entering buffers that don't fire
`BufWinEnter` but do fire `BufEnter`. Restore highlights when opening a buffer
that in a window that previously had cleared highlights.

# 0.2.9+1

Expand Down
3 changes: 3 additions & 0 deletions autoload/lsc/highlights.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function! lsc#highlights#clear() abort
endfor
endif
let w:lsc_diagnostic_matches = []
if exists('w:lsc_highlights_version')
unlet w:lsc_highlights_version
endif
endfunction

" If vim is in select or visual mode return true and attempt to schedule an
Expand Down
4 changes: 2 additions & 2 deletions plugin/lsc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ augroup LSC
" 1. Diagnostic highlights
" 2. Diagnostic location list
"
" The `BufWinEnter` event indicates most times when the buffer <-> window
" The `BufEnter` event indicates most times when the buffer <-> window
" relationship can change. There are some exceptions where this event is not
" fired such as `:split` and `:lopen` so `WinEnter` is used as a fallback with
" a block to ensure it only happens once.
autocmd BufWinEnter * call LSCEnsureCurrentWindowState()
autocmd BufEnter * call LSCEnsureCurrentWindowState()
autocmd WinEnter * call timer_start(1, function('<SID>OnWinEnter'))

" Window local state is only correctly maintained for the current tab.
Expand Down

0 comments on commit 8ea0d66

Please sign in to comment.