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>
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index c20ff48..a397f70 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -4215,4 +4215,22 @@
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