vimwiki

Personal wiki for vim
git clone https://github.com/vimwiki/vimwiki.git
Log | Files | Refs | README | LICENSE

commit 5247de4a0bb6eea640f0535b8ff1e7ca02d753dc
parent 0d3f526a884d4f24915f2b78fb655a3237898620
Author: Ivan Tishchenko <ivan.tishchenko@dsr-company.com>
Date:   Fri, 27 Nov 2015 03:20:44 +0300

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.

Diffstat:
Mautoload/vimwiki/base.vim | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim @@ -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 {{{