Mercurial > vim
changeset 34146:23bb675796f0 v9.1.0034
patch 9.1.0034: Window scrolls unexpectedly when 'scrollbind' is set
Commit: https://github.com/vim/vim/commit/ac4cffc6d9d307778d8a2945adab70244470bbb8
Author: Christian Brabandt <cb@256bit.org>
Date: Tue Jan 16 17:22:38 2024 +0100
patch 9.1.0034: Window scrolls unexpectedly when 'scrollbind' is set
Problem: Window may unexpectedly scroll when 'scrollbind' is set
and setting a buffer-local option using setbufvar()
(Boris Staletic)
Solution: Save and restore the windows topline before opening the
popup window.
fixes: #13863
closes: #13869
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 16 Jan 2024 17:30:10 +0100 |
parents | 358d769bbdd4 |
children | efe7982ac118 |
files | src/evalvars.c src/testdir/test_popupwin.vim src/version.c |
diffstat | 3 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -4924,6 +4924,10 @@ f_setbufvar(typval_T *argvars, typval_T if (*varname == '&') { aco_save_T aco; + // safe the current window position, it could + // change because of 'scrollbind' window-local + // options + linenr_T old_topline = curwin->w_topline; // Set curbuf to be our buf, temporarily. aucmd_prepbuf(&aco, buf); @@ -4935,6 +4939,7 @@ f_setbufvar(typval_T *argvars, typval_T // reset notion of buffer aucmd_restbuf(&aco); } + curwin->w_topline = old_topline; } else {
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -4215,4 +4215,22 @@ func Test_popup_close_callback_recursive set maxfuncdepth& endfunc +func Test_popupwin_setbufvar_changing_window_view() + " Test for Github Issue https://github.com/vim/vim/issues/13863 + " using setbufvar(buf, '&option') should not scroll + " the current window + 20new + call append(0, range(1, 25)) + setlocal scrollbind + norm! G + let topline = winsaveview()['topline'] + call setbufvar(winbufnr(popup_atcursor(['foobar'], {})), '&syntax', 'python') + " close popup + call popup_clear() + call assert_equal(topline, winsaveview()['topline']) + + " clean up + bw! +endfunc + " vim: shiftwidth=2 sts=2