Skip to content

Commit

Permalink
Delete highlight if buffer is switched in the same window
Browse files Browse the repository at this point in the history
Close #41
  • Loading branch information
machakann committed Mar 5, 2020
1 parent 8186b1a commit 931cc6b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions autoload/highlightedyank/highlight.vim
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function! s:highlight.add(...) dict abort "{{{
let self.bufnr = bufnr('%')
let self.winid = win_getid()
call self.switchtask.call(self.switch, [], self)
\.repeat(-1)
\.repeat(1)
\.waitfor(['BufEnter'])
let triggers = [['BufUnload', '<buffer>'], ['CmdwinLeave', '<buffer>'],
\ ['TextChanged', '*'], ['InsertEnter', '*'],
Expand Down Expand Up @@ -284,17 +284,15 @@ function! s:is_in_cmdline_window() abort "{{{
endfunction "}}}


" Toggle on/off when the displayed buffer is changed in the highlighting window
" Quench if buffer is switched in the same window
function! s:highlight.switch() abort "{{{
if win_getid() != self.winid
return
endif

if bufnr('%') == self.bufnr
call self.add()
else
call self.delete()
return
endif
call self.delete()
endfunction "}}}


Expand Down

0 comments on commit 931cc6b

Please sign in to comment.