mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -07:00
Avoid unnecessary tab/window switch
This commit is contained in:
parent
662274e617
commit
da47e6ee56
24
plug.vim
24
plug.vim
@ -506,23 +506,29 @@ function! s:switch_in()
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:pos = [tabpagenr(), winnr(), winsaveview()]
|
if winbufnr(0) != s:plug_buf
|
||||||
execute 'normal!' s:plug_tab.'gt'
|
let s:pos = [tabpagenr(), winnr(), winsaveview()]
|
||||||
let winnr = bufwinnr(s:plug_buf)
|
execute 'normal!' s:plug_tab.'gt'
|
||||||
execute winnr 'wincmd w'
|
let winnr = bufwinnr(s:plug_buf)
|
||||||
|
execute winnr.'wincmd w'
|
||||||
|
call add(s:pos, winsaveview())
|
||||||
|
else
|
||||||
|
let s:pos = [winsaveview()]
|
||||||
|
endif
|
||||||
|
|
||||||
call add(s:pos, winsaveview())
|
|
||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:switch_out()
|
function! s:switch_out()
|
||||||
call winrestview(s:pos[3])
|
call winrestview(s:pos[-1])
|
||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
|
|
||||||
execute 'normal!' s:pos[0].'gt'
|
if len(s:pos) > 1
|
||||||
execute s:pos[1] 'wincmd w'
|
execute 'normal!' s:pos[0].'gt'
|
||||||
call winrestview(s:pos[2])
|
execute s:pos[1] 'wincmd w'
|
||||||
|
call winrestview(s:pos[2])
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:prepare()
|
function! s:prepare()
|
||||||
|
Loading…
Reference in New Issue
Block a user