summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2022-03-15 09:46:54 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-15 09:46:54 +0000
commit10792feebd237aee89270669e509e85cafdfac60 (patch)
tree0c36b4443c24328d4e7f7ffbc5474f43f4ffdf8a
parent7a73252063242e88a6966e9d9ae7ea8beb897518 (diff)
patch 8.2.4568: getmousepos() does not compute the column below the last linev8.2.4568
Problem: getmousepos() does not compute the column below the last line. Solution: Also compute the column when the mouse is below the last line. (Sean Dewar, closes #9946)
-rw-r--r--src/mouse.c4
-rw-r--r--src/testdir/test_functions.vim23
-rw-r--r--src/version.c2
3 files changed, 27 insertions, 2 deletions
diff --git a/src/mouse.c b/src/mouse.c
index 25d6fa89a1..ffbe84219f 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -3099,8 +3099,8 @@ f_getmousepos(typval_T *argvars UNUSED, typval_T *rettv)
col -= left_off;
if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
{
- if (!mouse_comp_pos(wp, &row, &col, &lnum, NULL))
- col = vcol2col(wp, lnum, col);
+ (void)mouse_comp_pos(wp, &row, &col, &lnum, NULL);
+ col = vcol2col(wp, lnum, col);
column = col + 1;
}
}
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index d97522a37d..fddf4aeb63 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2783,6 +2783,29 @@ func Test_getmousepos()
\ line: 1,
\ column: 8,
\ }, getmousepos())
+
+ " If the mouse is positioned past the last buffer line, "line" and "column"
+ " should act like it's positioned on the last buffer line.
+ call test_setmouse(2, 25)
+ call assert_equal(#{
+ \ screenrow: 2,
+ \ screencol: 25,
+ \ winid: win_getid(),
+ \ winrow: 2,
+ \ wincol: 25,
+ \ line: 1,
+ \ column: 4,
+ \ }, getmousepos())
+ call test_setmouse(2, 50)
+ call assert_equal(#{
+ \ screenrow: 2,
+ \ screencol: 50,
+ \ winid: win_getid(),
+ \ winrow: 2,
+ \ wincol: 50,
+ \ line: 1,
+ \ column: 8,
+ \ }, getmousepos())
bwipe!
endfunc
diff --git a/src/version.c b/src/version.c
index 4a4aa75fea..c4a65f3414 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4568,
+/**/
4567,
/**/
4566,