summaryrefslogtreecommitdiffstats
path: root/src/mouse.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-03-13 12:06:07 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-13 12:06:07 +0000
commit986b0fd0c550d9834a3cc45dd87555c13152c391 (patch)
treeb3530c9948abf4198766e3695bd5402028fd1972 /src/mouse.c
parentbadf04f5c219743cd6645ff1f1fe88badf4af4c5 (diff)
patch 8.2.4555: getmousepos() returns the wrong columnv8.2.4555
Problem: getmousepos() returns the wrong column. (Ernie Rael) Solution: Limit to the text size, not the number of bytes.
Diffstat (limited to 'src/mouse.c')
-rw-r--r--src/mouse.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/mouse.c b/src/mouse.c
index 6a32cac9d0..a094df6bbb 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -3099,17 +3099,14 @@ 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)
{
- char_u *p;
int count;
mouse_comp_pos(wp, &row, &col, &line, NULL);
- // limit to text length plus one
- p = ml_get_buf(wp->w_buffer, line, FALSE);
- count = (int)STRLEN(p);
+ // limit to text size plus one
+ count = linetabsize(ml_get_buf(wp->w_buffer, line, FALSE));
if (col > count)
col = count;
-
column = col + 1;
}
}