Mercurial > vim
diff src/testdir/test_termcodes.vim @ 30809:ffdb7a6785af v9.0.0739
patch 9.0.0739: mouse column not correctly used for popup_setpos
Commit: https://github.com/vim/vim/commit/17822c507c03d509037c9ee5eee5cfbb201b3f01
Author: Yee Cheng Chin <ychin.git@gmail.com>
Date: Thu Oct 13 13:17:40 2022 +0100
patch 9.0.0739: mouse column not correctly used for popup_setpos
Problem: Mouse column not correctly used for popup_setpos.
Solution: Adjust off-by-one error and handle Visual line selection properly.
(Yee Cheng Chin, closes #11356)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Oct 2022 14:30:03 +0200 |
parents | ac908e454519 |
children | 0c30130f8c94 |
line wrap: on
line diff
--- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -1298,20 +1298,20 @@ func Test_term_mouse_popup_menu_setpos() call assert_equal([1, 10], [line('.'), col('.')], msg) call assert_equal('ran away', @", msg) - " Test for right click in visual mode before the selection + " Test for right click in visual mode right before the selection let @" = '' call cursor(1, 10) - call feedkeys('vee' .. MouseRightClickCode(1, 2) - \ .. MouseRightReleaseCode(1, 2) .. "\<Down>\<CR>", "x") - call assert_equal([1, 2], [line('.'), col('.')], msg) + call feedkeys('vee' .. MouseRightClickCode(1, 9) + \ .. MouseRightReleaseCode(1, 9) .. "\<Down>\<CR>", "x") + call assert_equal([1, 9], [line('.'), col('.')], msg) call assert_equal('', @", msg) - " Test for right click in visual mode after the selection + " Test for right click in visual mode right after the selection let @" = '' call cursor(1, 10) - call feedkeys('vee' .. MouseRightClickCode(1, 20) - \ .. MouseRightReleaseCode(1, 20) .. "\<Down>\<CR>", "x") - call assert_equal([1, 20], [line('.'), col('.')], msg) + call feedkeys('vee' .. MouseRightClickCode(1, 18) + \ .. MouseRightReleaseCode(1, 18) .. "\<Down>\<CR>", "x") + call assert_equal([1, 18], [line('.'), col('.')], msg) call assert_equal('', @", msg) " Test for right click in block-wise visual mode inside the selection @@ -1331,6 +1331,32 @@ func Test_term_mouse_popup_menu_setpos() call assert_equal('v', getregtype('"'), msg) call assert_equal('', @", msg) + " Test for right click in line-wise visual mode inside the selection + let @" = '' + call cursor(1, 16) + call feedkeys("V" .. MouseRightClickCode(1, 10) + \ .. MouseRightReleaseCode(1, 10) .. "\<Down>\<CR>", "x") + call assert_equal([1, 1], [line('.'), col('.')], msg) " After yanking, the cursor goes to 1,1 + call assert_equal("V", getregtype('"'), msg) + call assert_equal(len(getreg('"', 1, v:true)), 1, msg) + + " Test for right click in multi-line line-wise visual mode inside the selection + let @" = '' + call cursor(1, 16) + call feedkeys("Vj" .. MouseRightClickCode(2, 20) + \ .. MouseRightReleaseCode(2, 20) .. "\<Down>\<CR>", "x") + call assert_equal([1, 1], [line('.'), col('.')], msg) " After yanking, the cursor goes to 1,1 + call assert_equal("V", getregtype('"'), msg) + call assert_equal(len(getreg('"', 1, v:true)), 2, msg) + + " Test for right click in line-wise visual mode outside the selection + let @" = '' + call cursor(1, 16) + call feedkeys("V" .. MouseRightClickCode(2, 10) + \ .. MouseRightReleaseCode(2, 10) .. "\<Down>\<CR>", "x") + call assert_equal([2, 10], [line('.'), col('.')], msg) + call assert_equal("", @", msg) + " Try clicking on the status line let @" = '' call cursor(1, 10)