comparison src/testdir/test_popupwin.vim @ 17358:d1ea88736ebd v8.1.1678

patch 8.1.1678: using popup_menu() does not scroll to show the selected line commit https://github.com/vim/vim/commit/a901a37bae9f4e2848d6d7ac7b0875d72f43e1eb Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 13 16:38:50 2019 +0200 patch 8.1.1678: using popup_menu() does not scroll to show the selected line Problem: When using popup_menu() does not scroll to show the selected line. Solution: Scroll the text. (Naruhiko Nishino, closes https://github.com/vim/vim/issues/4651)
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Jul 2019 16:45:04 +0200
parents 102ed3a26a5d
children 6604ecb7a615
comparison
equal deleted inserted replaced
17357:6ca0988117dd 17358:d1ea88736ebd
1859 " clean up 1859 " clean up
1860 call StopVimInTerminal(buf) 1860 call StopVimInTerminal(buf)
1861 call delete('XtestPopupMenuMaxWidth') 1861 call delete('XtestPopupMenuMaxWidth')
1862 endfunc 1862 endfunc
1863 1863
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
1864 " vim: shiftwidth=2 sts=2 expandtab 1910 " vim: shiftwidth=2 sts=2 expandtab