Avoid unnecessary tab/window switch
This commit is contained in:
parent
662274e617
commit
da47e6ee56
1 changed files with 15 additions and 9 deletions
12
plug.vim
12
plug.vim
|
@ -506,23 +506,29 @@ function! s:switch_in()
|
|||
return 0
|
||||
endif
|
||||
|
||||
if winbufnr(0) != s:plug_buf
|
||||
let s:pos = [tabpagenr(), winnr(), winsaveview()]
|
||||
execute 'normal!' s:plug_tab.'gt'
|
||||
let winnr = bufwinnr(s:plug_buf)
|
||||
execute winnr 'wincmd w'
|
||||
|
||||
execute winnr.'wincmd w'
|
||||
call add(s:pos, winsaveview())
|
||||
else
|
||||
let s:pos = [winsaveview()]
|
||||
endif
|
||||
|
||||
setlocal modifiable
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:switch_out()
|
||||
call winrestview(s:pos[3])
|
||||
call winrestview(s:pos[-1])
|
||||
setlocal nomodifiable
|
||||
|
||||
if len(s:pos) > 1
|
||||
execute 'normal!' s:pos[0].'gt'
|
||||
execute s:pos[1] 'wincmd w'
|
||||
call winrestview(s:pos[2])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:prepare()
|
||||
|
|
Loading…
Reference in a new issue