File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ if !exists('g:hlyanked_hlgroup')
1919endif
2020
2121if ! exists (' g:hlyanked_timeout' )
22- g: hlyanked_timeout = 2000
22+ g: hlyanked_timeout = 400
2323endif
2424
2525# ----------------------------------------------------
@@ -29,12 +29,8 @@ var timer_id = -1
2929var match_id = -1
3030
3131def HighlightYanked ()
32- # Remove existing timers.
33- # In practice this is never needed, but still...
34- if timer_id != -1
35- timer_stop (timer_id)
36- timer_id = -1
37- endif
32+ # Remove leftover timers and highlights
33+ KillHighlight ()
3834
3935 # Get extremes of yanking: start = (l0, c0), end = (l1, c1)
4036 var l0 = line (" '[" )
@@ -58,8 +54,22 @@ def HighlightYanked()
5854enddef
5955
6056def RemoveHighlight (timer: number )
61- matchdelete (match_id)
62- match_id = -1
57+ if match_id != -1
58+ matchdelete (match_id)
59+ match_id = -1
60+ endif
61+ enddef
62+
63+ def StopTimer (timer: number )
64+ if timer_id != -1
65+ timer_stop (timer_id)
66+ timer_id = -1
67+ endif
68+ enddef
69+
70+ def KillHighlight ()
71+ StopTimer (timer_id)
72+ RemoveHighlight (match_id)
6373enddef
6474
6575augroup HighlightYanked
@@ -71,9 +81,5 @@ augroup END
7181
7282augroup KillHighlight
7383 autocmd !
74- autocmd WinLeave * if timer_id != -1
75- | timer_stop (timer_id)
76- | timer_id = -1
77- | RemoveHighlight (0 )
78- | endif
84+ autocmd WinLeave * KillHighlight ()
7985augroup END
You can’t perform that action at this time.
0 commit comments