Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -1764,6 +1764,42 @@ func Test_popup_scrollbar() call popup_setoptions(g:winid, #{border: [], close: 'button'}) call feedkeys("\<F5>\<LeftMouse>", "xt") endfunc + func Popup_filter(winid, key) + if a:key == 'j' + let line = popup_getoptions(a:winid).firstline + let nlines = line('$', a:winid) + let newline = line < nlines ? (line + 1) : nlines + call popup_setoptions(a:winid, #{firstline: newline}) + return v:true + elseif a:key == 'x' + call popup_close(a:winid) + return v:true + endif + endfunc + + func PopupScroll() + call popup_clear() + let text =<< trim END + 1 + 2 + 3 + 4 + long line long line long line long line long line long line + long line long line long line long line long line long line + long line long line long line long line long line long line + END + call popup_create(text, #{ + \ minwidth: 30, + \ maxwidth: 30, + \ minheight: 4, + \ maxheight: 4, + \ firstline: 1, + \ wrap: v:true, + \ scrollbar: v:true, + \ mapping: v:false, + \ filter: funcref('Popup_filter') + \ }) + endfunc map <silent> <F3> :call test_setmouse(5, 36)<CR> map <silent> <F4> :call test_setmouse(4, 42)<CR> map <silent> <F5> :call test_setmouse(7, 42)<CR> @@ -1811,6 +1847,15 @@ func Test_popup_scrollbar() call term_sendkeys(buf, ":\<CR>") call VerifyScreenDump(buf, 'Test_popupwin_scroll_10', {}) + " check size with non-wrapping lines + call term_sendkeys(buf, ":call PopupScroll()\<CR>") + call VerifyScreenDump(buf, 'Test_popupwin_scroll_11', {}) + + " check size with wrapping lines + call term_sendkeys(buf, "j") + call VerifyScreenDump(buf, 'Test_popupwin_scroll_12', {}) + call term_sendkeys(buf, "x") + " clean up call StopVimInTerminal(buf) call delete('XtestPopupScroll')