Manage WinLeave/WinEnter events
This commit is contained in:
parent
65cde0b6fe
commit
6bad3f4174
@ -80,14 +80,24 @@ function! s:overwin.pattern(pattern) abort
|
|||||||
let winpos = self.select_winpos(self.gather_poses_overwin(a:pattern), self.config.keys)
|
let winpos = self.select_winpos(self.gather_poses_overwin(a:pattern), self.config.keys)
|
||||||
if winpos is# -1
|
if winpos is# -1
|
||||||
else
|
else
|
||||||
let [winnr_str, pos] = winpos
|
call s:move_to_winpos(winpos)
|
||||||
let winnr = str2nr(winnr_str)
|
endif
|
||||||
if winnr is# winnr()
|
endfunction
|
||||||
normal! m`
|
|
||||||
else
|
" @param {{winnr: [lnum, cnum]}}
|
||||||
call s:move_to_win(winnr)
|
function! s:move_to_winpos(winpos) abort
|
||||||
endif
|
let [winnr_str, pos] = a:winpos
|
||||||
call cursor(pos)
|
let winnr = str2nr(winnr_str)
|
||||||
|
let is_win_moved = !(winnr is# winnr())
|
||||||
|
if is_win_moved
|
||||||
|
doautocmd WinLeave *
|
||||||
|
call s:move_to_win(winnr)
|
||||||
|
else
|
||||||
|
normal! m`
|
||||||
|
endif
|
||||||
|
call cursor(pos)
|
||||||
|
if is_win_moved
|
||||||
|
doautocmd WinEnter *
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -560,7 +570,7 @@ endfunction
|
|||||||
" @param {number} winnr
|
" @param {number} winnr
|
||||||
function! s:move_to_win(winnr) abort
|
function! s:move_to_win(winnr) abort
|
||||||
if a:winnr !=# winnr()
|
if a:winnr !=# winnr()
|
||||||
execute a:winnr . 'wincmd w'
|
execute 'noautocmd' a:winnr . 'wincmd w'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user