Prevent scrolling of large folds while filesave updates TOC.

During TOC update, screen sometimes scrolls -- most often I've seen this
when I'm working inside large enough fold (does not fit in one screen).

Fix uses winsaveview()/winrestview() instead of getpos()/setpos().
Winview pair would also manage scroll position on screen, not just
cursor position in text.
This commit is contained in:
Ivan Tishchenko 2015-11-27 03:20:44 +03:00
parent 0d3f526a88
commit 5247de4a0b

View File

@ -1143,8 +1143,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
return return
endif endif
let old_cursor_pos = getpos('.') let winview_save = winsaveview()
let cursor_line = old_cursor_pos[1] let cursor_line = winview_save.lnum
let is_cursor_after_listing = 0 let is_cursor_after_listing = 0
let is_fold_closed = 1 let is_fold_closed = 1
@ -1199,9 +1199,9 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
endif endif
if is_cursor_after_listing if is_cursor_after_listing
let old_cursor_pos[1] += lines_diff let winview_save.lnum += lines_diff
endif endif
call setpos('.', old_cursor_pos) call winrestview(winview_save)
endfunction "}}} endfunction "}}}
" WIKI link following functions {{{ " WIKI link following functions {{{