From deb2204bffa075ed5485415fc2dbd20e75d87ea4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 17 Mar 2024 19:44:30 +0100 Subject: patch 9.1.0186: cursor pos wrong on mouse click after eol with 'rl', 've' and conceal Problem: Wrong cursor position when clicking after end of line with 'rightleft', 'virtualedit' and conceal. Solution: Set values in ScreenCols[] also with SLF_RIGHTLEFT. Also fix off-by-one cursor position with 'colorcolumn' (zeertzjq). closes: #14218 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- src/testdir/test_conceal.vim | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/testdir') diff --git a/src/testdir/test_conceal.vim b/src/testdir/test_conceal.vim index 9696cdeae8..355817dd36 100644 --- a/src/testdir/test_conceal.vim +++ b/src/testdir/test_conceal.vim @@ -464,6 +464,53 @@ func Test_conceal_mouse_click() call test_setmouse(1, 32) call feedkeys("\", "tx") call assert_equal([0, 1, 24, 12, 36], getcurpos()) + " Behavior should also be the same with 'colorcolumn'. + setlocal colorcolumn=30 + redraw + call test_setmouse(1, 31) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 11, 35], getcurpos()) + call test_setmouse(1, 32) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 12, 36], getcurpos()) + setlocal colorcolumn& + + if has('rightleft') + setlocal rightleft + call assert_equal([ + \ ' ereh kcilc laecnoc', + \ ], ScreenLines(1, 40)) + " Click on the space between "this" and "click" puts cursor there. + call test_setmouse(1, 41 - 9) + call feedkeys("\", "tx") + call assert_equal([0, 1, 13, 0, 13], getcurpos()) + " Click on 'h' of "here" puts cursor there. + call test_setmouse(1, 41 - 16) + call feedkeys("\", "tx") + call assert_equal([0, 1, 20, 0, 20], getcurpos()) + " Click on 'e' of "here" puts cursor there. + call test_setmouse(1, 41 - 19) + call feedkeys("\", "tx") + call assert_equal([0, 1, 23, 0, 23], getcurpos()) + " Click after end of line puts cursor there with 'virtualedit'. + call test_setmouse(1, 41 - 20) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 0, 24], getcurpos()) + call test_setmouse(1, 41 - 21) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 1, 25], getcurpos()) + call test_setmouse(1, 41 - 22) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 2, 26], getcurpos()) + call test_setmouse(1, 41 - 31) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 11, 35], getcurpos()) + call test_setmouse(1, 41 - 32) + call feedkeys("\", "tx") + call assert_equal([0, 1, 24, 12, 36], getcurpos()) + setlocal rightleft& + endif + set virtualedit& " Test with a wrapped line. -- cgit v1.2.3