Mercurial > vim
diff src/mouse.c @ 30809:ffdb7a6785af v9.0.0739
patch 9.0.0739: mouse column not correctly used for popup_setpos
Commit: https://github.com/vim/vim/commit/17822c507c03d509037c9ee5eee5cfbb201b3f01
Author: Yee Cheng Chin <ychin.git@gmail.com>
Date: Thu Oct 13 13:17:40 2022 +0100
patch 9.0.0739: mouse column not correctly used for popup_setpos
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 #11356)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Oct 2022 14:30:03 +0200 |
parents | 101f08b49ed3 |
children | 013f8436b0d5 |
line wrap: on
line diff
--- a/src/mouse.c +++ b/src/mouse.c @@ -141,7 +141,9 @@ find_end_of_word(pos_T *pos) # define NEED_VCOL2COL /* - * Translate window coordinates to buffer position without any side effects + * Translate window coordinates to buffer position without any side effects. + * Returns IN_BUFFER and sets "mpos->col" to the column when in buffer text. + * The column is one for the first column. */ static int get_fpos_of_mouse(pos_T *mpos) @@ -172,8 +174,6 @@ get_fpos_of_mouse(pos_T *mpos) mpos->col = vcol2col(wp, mpos->lnum, col); - if (mpos->col > 0) - --mpos->col; mpos->coladd = 0; return IN_BUFFER; } @@ -598,7 +598,19 @@ do_mouse( jump_flags = MOUSE_MAY_STOP_VIS; else { - if ((LT_POS(curwin->w_cursor, VIsual) + 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_POS(curwin->w_cursor, VIsual) && (LT_POS(m_pos, curwin->w_cursor) || LT_POS(VIsual, m_pos))) || (LT_POS(VIsual, curwin->w_cursor)