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:
parent
0d3f526a88
commit
5247de4a0b
@ -1143,8 +1143,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
return
|
||||
endif
|
||||
|
||||
let old_cursor_pos = getpos('.')
|
||||
let cursor_line = old_cursor_pos[1]
|
||||
let winview_save = winsaveview()
|
||||
let cursor_line = winview_save.lnum
|
||||
let is_cursor_after_listing = 0
|
||||
|
||||
let is_fold_closed = 1
|
||||
@ -1199,9 +1199,9 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
endif
|
||||
|
||||
if is_cursor_after_listing
|
||||
let old_cursor_pos[1] += lines_diff
|
||||
let winview_save.lnum += lines_diff
|
||||
endif
|
||||
call setpos('.', old_cursor_pos)
|
||||
call winrestview(winview_save)
|
||||
endfunction "}}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
|
Loading…
Reference in New Issue
Block a user