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/dumps/Test_popupwin_set_firstline_1.dump b/src/testdir/dumps/Test_popupwin_set_firstline_1.dump
new file mode 100644
index 0000000..7d8c20d
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_set_firstline_1.dump
@@ -0,0 +1,16 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @25|1+0#0000001#e0e0e08|0| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255@1| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|2| @17| +0#0000000#0000001| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|3| @17| +0#0000000#0000001| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|4| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|5| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|6| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|7| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|8| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|9| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|2+0#0000001#ffd7ff255|0| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @73
+|~| @73
+| +0#0000000&@56|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/dumps/Test_popupwin_set_firstline_2.dump b/src/testdir/dumps/Test_popupwin_set_firstline_2.dump
new file mode 100644
index 0000000..5744eaf
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_set_firstline_2.dump
@@ -0,0 +1,16 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @25|5+0#0000001#ffd7ff255| @18| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|6+0#0000001#ffd7ff255| @18| +0#0000000#0000001| +0#4040ff13#ffffff0@26
+|~| @25|7+0#0000001#ffd7ff255| @18| +0#0000000#0000001| +0#4040ff13#ffffff0@26
+|~| @25|8+0#0000001#ffd7ff255| @18| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|9+0#0000001#ffd7ff255| @18| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#e0e0e08|0| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255@1| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|2| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|3| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|4| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @25|1+0#0000001#ffd7ff255|5| @17| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@26
+|~| @73
+|~| @73
+|:+0#0000000&| @55|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump b/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump
index 76f85dc..e29dca9 100644
--- a/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump
+++ b/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump
@@ -1,14 +1,14 @@
> +0&#ffffff0@74
|~+0#4040ff13&| @73
+|~| @34|1+0#0000001#ffd7ff255|3| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
|~| @34|1+0#0000001#ffd7ff255|4| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
|~| @34|1+0#0000001#ffd7ff255|5| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
|~| @34|1+0#0000001#ffd7ff255|6| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
-|~| @34|1+0#0000001#e0e0e08|7| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
+|~| @34|1+0#0000001#e0e0e08|7| +0#0000000#0000001| +0#4040ff13#ffffff0@35
|~| @34|1+0#0000001#ffd7ff255|8| +0#0000000#0000001| +0#4040ff13#ffffff0@35
|~| @34|1+0#0000001#ffd7ff255|9| +0#0000000#0000001| +0#4040ff13#ffffff0@35
-|~| @34|2+0#0000001#ffd7ff255|0| +0#0000000#0000001| +0#4040ff13#ffffff0@35
+|~| @34|2+0#0000001#ffd7ff255|0| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
|~| @34|2+0#0000001#ffd7ff255|1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
-|~| @34|2+0#0000001#ffd7ff255@1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35
|~| @73
|~| @73
|:+0#0000000&| @55|0|,|0|-|1| @8|A|l@1|
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