comparison src/testdir/test_popupwin.vim @ 18492:41a5f241e9d5 v8.1.2240

patch 8.1.2240: popup window width changes when scrolling Commit: https://github.com/vim/vim/commit/f2885d3fb7045d14ae58824e9cb8dea65e4052c4 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 2 20:21:25 2019 +0100 patch 8.1.2240: popup window width changes when scrolling Problem: Popup window width changes when scrolling. Solution: Also adjust maxwidth when applying minwidth and there is a scrollbar. Fix off-by-one error. (closes #5162)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Nov 2019 20:30:03 +0100
parents ee8db42dacf6
children 04a40c1514c4
comparison
equal deleted inserted replaced
18491:2ccbede92fd5 18492:41a5f241e9d5
1762 endfunc 1762 endfunc
1763 func ClickBot() 1763 func ClickBot()
1764 call popup_setoptions(g:winid, #{border: [], close: 'button'}) 1764 call popup_setoptions(g:winid, #{border: [], close: 'button'})
1765 call feedkeys("\<F5>\<LeftMouse>", "xt") 1765 call feedkeys("\<F5>\<LeftMouse>", "xt")
1766 endfunc 1766 endfunc
1767 func Popup_filter(winid, key)
1768 if a:key == 'j'
1769 let line = popup_getoptions(a:winid).firstline
1770 let nlines = line('$', a:winid)
1771 let newline = line < nlines ? (line + 1) : nlines
1772 call popup_setoptions(a:winid, #{firstline: newline})
1773 return v:true
1774 elseif a:key == 'x'
1775 call popup_close(a:winid)
1776 return v:true
1777 endif
1778 endfunc
1779
1780 func PopupScroll()
1781 call popup_clear()
1782 let text =<< trim END
1783 1
1784 2
1785 3
1786 4
1787 long line long line long line long line long line long line
1788 long line long line long line long line long line long line
1789 long line long line long line long line long line long line
1790 END
1791 call popup_create(text, #{
1792 \ minwidth: 30,
1793 \ maxwidth: 30,
1794 \ minheight: 4,
1795 \ maxheight: 4,
1796 \ firstline: 1,
1797 \ wrap: v:true,
1798 \ scrollbar: v:true,
1799 \ mapping: v:false,
1800 \ filter: funcref('Popup_filter')
1801 \ })
1802 endfunc
1767 map <silent> <F3> :call test_setmouse(5, 36)<CR> 1803 map <silent> <F3> :call test_setmouse(5, 36)<CR>
1768 map <silent> <F4> :call test_setmouse(4, 42)<CR> 1804 map <silent> <F4> :call test_setmouse(4, 42)<CR>
1769 map <silent> <F5> :call test_setmouse(7, 42)<CR> 1805 map <silent> <F5> :call test_setmouse(7, 42)<CR>
1770 END 1806 END
1771 call writefile(lines, 'XtestPopupScroll') 1807 call writefile(lines, 'XtestPopupScroll')
1808 1844
1809 " remove the minwidth and maxheight 1845 " remove the minwidth and maxheight
1810 call term_sendkeys(buf, ":call popup_setoptions(winid, #{maxheight: 0, minwidth: 0})\<CR>") 1846 call term_sendkeys(buf, ":call popup_setoptions(winid, #{maxheight: 0, minwidth: 0})\<CR>")
1811 call term_sendkeys(buf, ":\<CR>") 1847 call term_sendkeys(buf, ":\<CR>")
1812 call VerifyScreenDump(buf, 'Test_popupwin_scroll_10', {}) 1848 call VerifyScreenDump(buf, 'Test_popupwin_scroll_10', {})
1849
1850 " check size with non-wrapping lines
1851 call term_sendkeys(buf, ":call PopupScroll()\<CR>")
1852 call VerifyScreenDump(buf, 'Test_popupwin_scroll_11', {})
1853
1854 " check size with wrapping lines
1855 call term_sendkeys(buf, "j")
1856 call VerifyScreenDump(buf, 'Test_popupwin_scroll_12', {})
1857 call term_sendkeys(buf, "x")
1813 1858
1814 " clean up 1859 " clean up
1815 call StopVimInTerminal(buf) 1860 call StopVimInTerminal(buf)
1816 call delete('XtestPopupScroll') 1861 call delete('XtestPopupScroll')
1817 endfunc 1862 endfunc