patch 8.1.2192: cannot easily fill the info popup asynchronously
Problem: Cannot easily fill the info popup asynchronously.
Solution: Add the "popuphidden" value to 'completeopt'. (closes #4924)
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index e84527b..2e2d1df 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -2498,6 +2498,41 @@
let id = popup_findinfo()
eval id->popup_setoptions(#{highlight: 'InfoPopup'})
endfunc
+
+ func InfoHidden()
+ set completepopup=height:4,border:off,align:menu
+ set completeopt-=popup completeopt+=popuphidden
+ au CompleteChanged * call HandleChange()
+ endfunc
+
+ let s:counter = 0
+ func HandleChange()
+ let s:counter += 1
+ let selected = complete_info(['selected']).selected
+ if selected <= 0
+ " First time: do nothing, info remains hidden
+ return
+ endif
+ if selected == 1
+ " Second time: show info right away
+ let id = popup_findinfo()
+ if id
+ call popup_settext(id, 'immediate info ' .. s:counter)
+ call popup_show(id)
+ endif
+ else
+ " Third time: show info after a short delay
+ call timer_start(100, 'ShowInfo')
+ endif
+ endfunc
+
+ func ShowInfo(...)
+ let id = popup_findinfo()
+ if id
+ call popup_settext(id, 'async info ' .. s:counter)
+ call popup_show(id)
+ endif
+ endfunc
END
return lines
endfunc
@@ -2580,6 +2615,30 @@
call delete('XtestInfoPopupNb')
endfunc
+func Test_popupmenu_info_hidden()
+ CheckScreendump
+
+ let lines = Get_popupmenu_lines()
+ call add(lines, 'call InfoHidden()')
+ call writefile(lines, 'XtestInfoPopupHidden')
+
+ let buf = RunVimInTerminal('-S XtestInfoPopupHidden', #{rows: 14})
+ call term_wait(buf, 50)
+
+ call term_sendkeys(buf, "A\<C-X>\<C-U>")
+ call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_1', {})
+
+ call term_sendkeys(buf, "\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_2', {})
+
+ call term_sendkeys(buf, "\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_3', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ call delete('XtestInfoPopupHidden')
+endfunc
+
func Test_popupwin_recycle_bnr()
let bufnr = popup_notification('nothing wrong', {})->winbufnr()
call popup_clear()