patch 8.1.1622: wrong width if displaying a lot of lines in a popup window

Problem:    Wrong width if displaying a lot of lines in a popup window.
Solution:   Accurately compute the line overflow.
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index cc25976..f7579f5 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -1697,3 +1697,16 @@
   redraw
   call popup_close(winid)
 endfunc
+
+func Test_popupwin_width()
+  let winid = popup_create(repeat(['short', 'long long long line', 'medium width'], 50), {
+	\ 'maxwidth': 40,
+	\ 'maxheight': 10,
+	\ })
+  for top in range(1, 20)
+    call popup_setoptions(winid, {'firstline': top})
+    redraw
+    call assert_equal(19, popup_getpos(winid).width)
+  endfor
+  call popup_clear()
+endfunc