mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.4555: getmousepos() returns the wrong column
Problem: getmousepos() returns the wrong column. (Ernie Rael) Solution: Limit to the text size, not the number of bytes.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user