I see a case in which winrestview() work incorrectly after PageDown near end-of-file. (This is in the context of scrollfix plugin.)
To reproduce: % vim -u NONE -c 'so x.vim' # x.vim is below :help help " have some text :set nu " see line numbers press seevral ArrowDown to see how x.vim works, works OK, cursor is on 5th line G OK, cursor is on 5th line <PageDown> -- now this seems to be a bug, cursor is at top line instead of 5th line :echo g:last " g:last shows how the last winrestview() was performed {'lnum': 7336, 'leftcol': 0, 'col': 1, 'topfill': 0, 'topline': 7332, 'coladd': 0, 'skipc ol': 0, 'curswant': 1} NB: 'topline' is 7332 but winrestview() incorrectly ignored the 'topline'. The same wrong behaviour can be observed even with small 3-line file. Yakov ---------------------- x.vim ------------------------- :let g:scroll_fix=5 :let so=0 aug scrollfix au! au CursorMoved * :call ScrollFix() aug END function! ScrollFix() if g:scroll_fix==0 | return | endif if &so!=0 | set so=0|endif " keep cursor on fixed visual line of the window let dict = winsaveview() if dict['lnum'] <= g:scroll_fix | return | endif if dict['lnum'] - dict['topline'] + 1 == g:scroll_fix | return | endif let dict['topline'] = dict['lnum'] - g:scroll_fix + 1 let g:last = dict call winrestview(dict) endfunction -----------------------------------------------------------------------------