diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-04 17:26:37 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-07-04 17:26:37 +0200 |
commit | 761a420c66402545acd8ee3ffa17c3a1fc3110e4 (patch) | |
tree | 3613e94ca327e1baf854addb75020b163c842411 /src/testdir/test_menu.vim | |
parent | 7ccd1a2e858dbb2ac7fb09971dfcbfad62baa677 (diff) |
patch 9.1.0525: Right release selects immediately when pum is truncated.v9.1.0525
Problem: Right release selects immediately when pum is truncated.
Solution: Use pum_height instead of pum_size when checking click row.
Don't place it above mouse row when there is more space below.
(zeertzjq)
fixes: #15101
closes: #15102
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_menu.vim')
-rw-r--r-- | src/testdir/test_menu.vim | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/testdir/test_menu.vim b/src/testdir/test_menu.vim index 22292289ee..40fec4058a 100644 --- a/src/testdir/test_menu.vim +++ b/src/testdir/test_menu.vim @@ -481,13 +481,48 @@ func Test_popup_menu() unmenu PopUp endfunc +func Test_popup_menu_truncated() + CheckNotGui + + set mouse=a mousemodel=popup + aunmenu PopUp + for i in range(2 * &lines) + exe $'menu PopUp.{i} <Cmd>let g:res = {i}<CR>' + endfor + + func LeftClickExpr(row, col) + call test_setmouse(a:row, a:col) + return "\<LeftMouse>" + endfunc + + " Clicking at the bottom should place popup menu above click position. + " <RightRelease> should not select an item immediately. + let g:res = -1 + call test_setmouse(&lines, 1) + nnoremap <expr><F2> LeftClickExpr(4, 1) + call feedkeys("\<RightMouse>\<RightRelease>\<F2>", 'tx') + call assert_equal(3, g:res) + + " Clicking at the top should place popup menu below click position. + let g:res = -1 + call test_setmouse(1, 1) + nnoremap <expr><F2> LeftClickExpr(5, 1) + call feedkeys("\<RightMouse>\<RightRelease>\<F2>", 'tx') + call assert_equal(3, g:res) + + nunmap <F2> + delfunc LeftClickExpr + unlet g:res + aunmenu PopUp + set mouse& mousemodel& +endfunc + " Test for MenuPopup autocommand func Test_autocmd_MenuPopup() CheckNotGui - set mouse=a - set mousemodel=popup - aunmenu * + set mouse=a mousemodel=popup + aunmenu PopUp autocmd MenuPopup * exe printf( \ 'anoremenu PopUp.Foo <Cmd>let g:res = ["%s", "%s"]<CR>', \ expand('<afile>'), expand('<amatch>')) |