mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.4568: getmousepos() does not compute the column below the last line
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)
This commit is contained in:
committed by
Bram Moolenaar
parent
7a73252063
commit
10792feebd
@@ -3099,8 +3099,8 @@ f_getmousepos(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
col -= left_off;
|
col -= left_off;
|
||||||
if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
|
if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
|
||||||
{
|
{
|
||||||
if (!mouse_comp_pos(wp, &row, &col, &lnum, NULL))
|
(void)mouse_comp_pos(wp, &row, &col, &lnum, NULL);
|
||||||
col = vcol2col(wp, lnum, col);
|
col = vcol2col(wp, lnum, col);
|
||||||
column = col + 1;
|
column = col + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2783,6 +2783,29 @@ func Test_getmousepos()
|
|||||||
\ line: 1,
|
\ line: 1,
|
||||||
\ column: 8,
|
\ column: 8,
|
||||||
\ }, getmousepos())
|
\ }, 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!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4568,
|
||||||
/**/
|
/**/
|
||||||
4567,
|
4567,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user