@@ -1861,4 +1861,50 @@ func Test_popup_menu_with_maxwidth()
18611861 call delete (' XtestPopupMenuMaxWidth' )
18621862endfunc
18631863
1864+ func Test_popup_menu_with_scrollbar ()
1865+ if ! CanRunVimInTerminal ()
1866+ throw ' Skipped: cannot make screendumps'
1867+ endif
1868+
1869+ let lines = << trim END
1870+ call setline (1 , range (1 , 20 ))
1871+ hi ScrollThumb ctermbg= blue
1872+ hi ScrollBar ctermbg= red
1873+ call popup_menu ([' one' , ' two' , ' three' , ' four' , ' five' ,
1874+ \ ' six' , ' seven' , ' eight' , ' nine' ], {
1875+ \ ' minwidth' : 8 ,
1876+ \ ' maxheight' : 3 ,
1877+ \ })
1878+ END
1879+ call writefile (lines , ' XtestPopupMenuScroll' )
1880+ let buf = RunVimInTerminal (' -S XtestPopupMenuScroll' , {' rows' : 10 })
1881+
1882+ call term_sendkeys (buf , " j" )
1883+ call VerifyScreenDump (buf , ' Test_popupwin_menu_scroll_1' , {})
1884+
1885+ call term_sendkeys (buf , " jjj" )
1886+ call VerifyScreenDump (buf , ' Test_popupwin_menu_scroll_2' , {})
1887+
1888+ " if the cursor is the bottom line, it stays at the bottom line.
1889+ call term_sendkeys (buf , repeat (" j" , 20 ))
1890+ call VerifyScreenDump (buf , ' Test_popupwin_menu_scroll_3' , {})
1891+
1892+ call term_sendkeys (buf , " kk" )
1893+ call VerifyScreenDump (buf , ' Test_popupwin_menu_scroll_4' , {})
1894+
1895+ call term_sendkeys (buf , " k" )
1896+ call VerifyScreenDump (buf , ' Test_popupwin_menu_scroll_5' , {})
1897+
1898+ " if the cursor is in the top line, it stays in the top line.
1899+ call term_sendkeys (buf , repeat (" k" , 20 ))
1900+ call VerifyScreenDump (buf , ' Test_popupwin_menu_scroll_6' , {})
1901+
1902+ " close the menu popupwin.
1903+ call term_sendkeys (buf , " " )
1904+
1905+ " clean up
1906+ call StopVimInTerminal (buf )
1907+ call delete (' XtestPopupMenuScroll' )
1908+ endfunc
1909+
18641910" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments