patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu

Problem:    CTRL-A does not work properly with the cmdline popup menu.
Solution:   Fix issues with CTRL-A.  Add more tests for the cmdline popup
            menu.  Remove TermWait() before VeriryScreenDump().  Refactor the
            cmdline popup code. (Yegappan Lakshmanan, closes #9735)
diff --git a/src/testdir/screendump.vim b/src/testdir/screendump.vim
index 8ea708a..8fc496d 100644
--- a/src/testdir/screendump.vim
+++ b/src/testdir/screendump.vim
@@ -27,6 +27,9 @@
   " Starting a terminal to make a screendump is always considered flaky.
   let g:test_is_flaky = 1
 
+  " wait for the pending updates to be handled.
+  call TermWait(a:buf)
+
   " Redraw to execute the code that updates the screen.  Otherwise we get the
   " text and attributes only from the internal buffer.
   redraw