vim-patch:9.0.0739: mouse column not correctly used for popup_setpos (#20729)

Problem:    Mouse column not correctly used for popup_setpos.
Solution:   Adjust off-by-one error and handle Visual line selection properly.
            (Yee Cheng Chin, closes vim/vim#11356)
17822c507c

The test_termcodes.vim test cannot be used. Use a Lua test instead.
This commit is contained in:
zeertzjq
2022-10-19 11:32:26 +08:00
committed by GitHub
parent a5d893bebd
commit 96cf385a7f
3 changed files with 144 additions and 8 deletions

View File

@@ -1820,10 +1820,17 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
} else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER) {
jump_flags = MOUSE_MAY_STOP_VIS;
} else {
if ((lt(curwin->w_cursor, VIsual)
&& (lt(m_pos, curwin->w_cursor) || lt(VIsual, m_pos)))
|| (lt(VIsual, curwin->w_cursor)
&& (lt(m_pos, VIsual) || lt(curwin->w_cursor, m_pos)))) {
if (VIsual_mode == 'V') {
if ((curwin->w_cursor.lnum <= VIsual.lnum
&& (m_pos.lnum < curwin->w_cursor.lnum || VIsual.lnum < m_pos.lnum))
|| (VIsual.lnum < curwin->w_cursor.lnum
&& (m_pos.lnum < VIsual.lnum || curwin->w_cursor.lnum < m_pos.lnum))) {
jump_flags = MOUSE_MAY_STOP_VIS;
}
} else if ((ltoreq(curwin->w_cursor, VIsual)
&& (lt(m_pos, curwin->w_cursor) || lt(VIsual, m_pos)))
|| (lt(VIsual, curwin->w_cursor)
&& (lt(m_pos, VIsual) || lt(curwin->w_cursor, m_pos)))) {
jump_flags = MOUSE_MAY_STOP_VIS;
} else if (VIsual_mode == Ctrl_V) {
getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);