patch 8.2.1750: popup_setoptions() setting firstline fails if cursorline set
Problem: Setting firstline with popup_setoptions() fails if cursorline is
set.
Solution: Use apply_options(). Update the popup before applying "zz".
(closes #7010)
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 84362a2..65a6805 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -1581,6 +1581,34 @@
call delete('XtestPopupWinExecute')
endfunc
+func Test_popup_set_firstline()
+ CheckScreendump
+
+ let lines =<< trim END
+ let lines = range(1, 50)->map({_, v -> string(v)})
+ let g:id = popup_create(lines, #{
+ \ minwidth: 20,
+ \ maxwidth: 20,
+ \ minheight: &lines - 5,
+ \ maxheight: &lines - 5,
+ \ cursorline: 1,
+ \ })
+ call popup_setoptions(g:id, #{firstline: 10})
+ redraw
+ END
+ call writefile(lines, 'XtestPopupWinSetFirstline')
+ let buf = RunVimInTerminal('-S XtestPopupWinSetFirstline', #{rows: 16})
+
+ call VerifyScreenDump(buf, 'Test_popupwin_set_firstline_1', {})
+
+ call term_sendkeys(buf, ":call popup_setoptions(g:id, #{firstline: 5})\<CR>")
+ call term_sendkeys(buf, ":\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_set_firstline_2', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XtestPopupWinSetFirstline')
+endfunc
+
" this tests that we don't get stuck with an error in "win_execute()"
func Test_popup_filter_win_execute_error()
CheckScreendump