summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-09 14:19:40 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-09 14:19:40 +0100
commit8f49e690dc7b6ed521fb11431e2a406d01c4de3a (patch)
tree34dee1c7ff7f87c750b3dc218b3492dacefefd9b /src/testdir
parent8ca29b6a3599b82b8822b7697cad63d0244c2d59 (diff)
downloadvim-git-8f49e690dc7b6ed521fb11431e2a406d01c4de3a.tar.gz
patch 9.0.0177: cursor position wrong with 'virtualedit' and mouse clickv9.0.0177
Problem: Cursor position wrong with 'virtualedit' and mouse click after end of the line. (Hermann Mayer) Solution: Do not use ScreenCols[] when 'virtualedit' is active. (closes #10868)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_virtualedit.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim
index b31f3a2b4..8fd6d9844 100644
--- a/src/testdir/test_virtualedit.vim
+++ b/src/testdir/test_virtualedit.vim
@@ -537,4 +537,39 @@ func Test_global_local_virtualedit()
set virtualedit&
endfunc
+func Test_virtualedit_mouse()
+ let save_mouse = &mouse
+ set mouse=a
+ set virtualedit=all
+ new
+
+ call setline(1, ["text\tword"])
+ redraw
+ call test_setmouse(1, 4)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 4, 0, 4], getcurpos())
+ call test_setmouse(1, 5)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 5, 0, 5], getcurpos())
+ call test_setmouse(1, 6)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 5, 1, 6], getcurpos())
+ call test_setmouse(1, 7)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 5, 2, 7], getcurpos())
+ call test_setmouse(1, 8)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 5, 3, 8], getcurpos())
+ call test_setmouse(1, 9)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 6, 0, 9], getcurpos())
+ call test_setmouse(1, 15)
+ call feedkeys("\<LeftMouse>", "xt")
+ call assert_equal([0, 1, 10, 2, 15], getcurpos())
+
+ bwipe!
+ let &mouse = save_mouse
+ set virtualedit&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab