From c95845f3df256c6d0a15e959d2d2133bfe3b2d43 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Dec 2023 05:58:48 +0800 Subject: vim-patch:9.0.2177: Wrong cursor position when dragging out of window (#26661) Problem: Wrong cursor position when dragging out of window. Solution: Don't use ScreenCols[] when mouse is not in current window. closes: vim/vim#13717 https://github.com/vim/vim/commit/ec14924368e23f2430815c009bd554f88de9c57f --- test/old/testdir/test_visual.vim | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim index 5d70492451..b09078352e 100644 --- a/test/old/testdir/test_visual.vim +++ b/test/old/testdir/test_visual.vim @@ -1589,6 +1589,41 @@ func Test_Visual_r_CTRL_C() call feedkeys("\$gr\", 'tx') call assert_equal([''], getline(1, 1)) bw! -endfu +endfunc + +func Test_visual_drag_out_of_window() + rightbelow vnew + call setline(1, '123456789') + set mouse=a + func ClickExpr(off) + call Ntest_setmouse(1, getwininfo(win_getid())[0].wincol + a:off) + return "\" + endfunc + func DragExpr(off) + call Ntest_setmouse(1, getwininfo(win_getid())[0].wincol + a:off) + return "\" + endfunc + + nnoremap ClickExpr(5) + nnoremap DragExpr(-1) + redraw + call feedkeys("\\\", 'tx') + call assert_equal([1, 6], [col('.'), col('v')]) + call feedkeys("\", 'tx') + + nnoremap ClickExpr(6) + nnoremap DragExpr(-2) + redraw + call feedkeys("\\\", 'tx') + call assert_equal([1, 7], [col('.'), col('v')]) + call feedkeys("\", 'tx') + + nunmap + nunmap + delfunc ClickExpr + delfunc DragExpr + set mouse& + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit