Avoid screen jumps when scrolled to second region

This commit is contained in:
Tom McDonald 2015-08-01 15:19:51 -04:00
parent f8f96d83ce
commit e12149d5d6

View File

@ -16,6 +16,8 @@ function! s:exchange(x, y, reverse, expand)
let yindent = matchstr(getline(nextnonblank(a:x.start.line)), '^\s*') let yindent = matchstr(getline(nextnonblank(a:x.start.line)), '^\s*')
endif endif
let view = winsaveview()
call s:setpos("'[", a:y.start) call s:setpos("'[", a:y.start)
call s:setpos("']", a:y.end) call s:setpos("']", a:y.end)
call setreg('z', a:x.text, a:x.type) call setreg('z', a:x.text, a:x.type)
@ -37,6 +39,8 @@ function! s:exchange(x, y, reverse, expand)
call s:reindent(a:y.start.line - xlines + ylines, xlines, xindent) call s:reindent(a:y.start.line - xlines + ylines, xlines, xindent)
endif endif
call winrestview(view)
if a:reverse if a:reverse
call cursor(a:x.start.line, a:x.start.column) call cursor(a:x.start.line, a:x.start.column)
else else