diff src/testdir/test_popupwin.vim @ 22403:3351d2cd3f1f v8.2.1750

patch 8.2.1750: popup_setoptions() setting firstline fails if cursorline set Commit: https://github.com/vim/vim/commit/3697c9bbae755831d3cf2f11179aaff29e343f51 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 26 22:03:00 2020 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Sep 2020 22:15:04 +0200
parents b2cb2a321af9
children 909ce065e99a
line wrap: on
line diff
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -1581,6 +1581,34 @@ func Test_popup_filter_win_execute()
   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