Store and restore scrolloff value
Having &scrolloff > 0 caused an issue where backwards searches would scroll during the searchpos() call and hide parts of the buffer. This fix temporarily sets scrolloff to 0 during function execution.
This commit is contained in:
parent
07a20e382d
commit
98384b9e49
@ -260,6 +260,10 @@
|
|||||||
let targets = []
|
let targets = []
|
||||||
let visualmode = a:0 > 0 ? a:1 : ''
|
let visualmode = a:0 > 0 ? a:1 : ''
|
||||||
|
|
||||||
|
" Store original scrolloff value
|
||||||
|
let scrolloff = &scrolloff
|
||||||
|
setl scrolloff=0
|
||||||
|
|
||||||
" Find motion targets
|
" Find motion targets
|
||||||
while 1
|
while 1
|
||||||
let search_direction = (a:direction == 1 ? 'b' : '')
|
let search_direction = (a:direction == 1 ? 'b' : '')
|
||||||
@ -291,6 +295,9 @@
|
|||||||
" Restore cursor position
|
" Restore cursor position
|
||||||
call setpos('.', [0, orig_pos[0], orig_pos[1]])
|
call setpos('.', [0, orig_pos[0], orig_pos[1]])
|
||||||
|
|
||||||
|
" Restore original scrolloff value
|
||||||
|
execute 'setl scrolloff=' . scrolloff
|
||||||
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -349,6 +356,9 @@
|
|||||||
call setpos('.', [0, orig_pos[0], orig_pos[1]])
|
call setpos('.', [0, orig_pos[0], orig_pos[1]])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Restore original scrolloff value
|
||||||
|
execute 'setl scrolloff=' . scrolloff
|
||||||
|
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
if ! empty(visualmode)
|
if ! empty(visualmode)
|
||||||
@ -371,6 +381,9 @@
|
|||||||
call setpos('.', [0, coords[0], coords[1]])
|
call setpos('.', [0, coords[0], coords[1]])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Restore original scrolloff value
|
||||||
|
execute 'setl scrolloff=' . scrolloff
|
||||||
|
|
||||||
call <SID>Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
call <SID>Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user