comparison 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
comparison
equal deleted inserted replaced
30808:384b77639588 30809:ffdb7a6785af
139 || defined(FEAT_TERM_POPUP_MENU) 139 || defined(FEAT_TERM_POPUP_MENU)
140 # define USE_POPUP_SETPOS 140 # define USE_POPUP_SETPOS
141 # define NEED_VCOL2COL 141 # define NEED_VCOL2COL
142 142
143 /* 143 /*
144 * Translate window coordinates to buffer position without any side effects 144 * Translate window coordinates to buffer position without any side effects.
145 * Returns IN_BUFFER and sets "mpos->col" to the column when in buffer text.
146 * The column is one for the first column.
145 */ 147 */
146 static int 148 static int
147 get_fpos_of_mouse(pos_T *mpos) 149 get_fpos_of_mouse(pos_T *mpos)
148 { 150 {
149 win_T *wp; 151 win_T *wp;
170 if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL)) 172 if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL))
171 return IN_STATUS_LINE; // past bottom 173 return IN_STATUS_LINE; // past bottom
172 174
173 mpos->col = vcol2col(wp, mpos->lnum, col); 175 mpos->col = vcol2col(wp, mpos->lnum, col);
174 176
175 if (mpos->col > 0)
176 --mpos->col;
177 mpos->coladd = 0; 177 mpos->coladd = 0;
178 return IN_BUFFER; 178 return IN_BUFFER;
179 } 179 }
180 #endif 180 #endif
181 181
596 jump_flags = MOUSE_MAY_STOP_VIS; 596 jump_flags = MOUSE_MAY_STOP_VIS;
597 else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER) 597 else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER)
598 jump_flags = MOUSE_MAY_STOP_VIS; 598 jump_flags = MOUSE_MAY_STOP_VIS;
599 else 599 else
600 { 600 {
601 if ((LT_POS(curwin->w_cursor, VIsual) 601 if (VIsual_mode == 'V')
602 {
603 if ((curwin->w_cursor.lnum <= VIsual.lnum
604 && (m_pos.lnum < curwin->w_cursor.lnum
605 || VIsual.lnum < m_pos.lnum))
606 || (VIsual.lnum < curwin->w_cursor.lnum
607 && (m_pos.lnum < VIsual.lnum
608 || curwin->w_cursor.lnum < m_pos.lnum)))
609 {
610 jump_flags = MOUSE_MAY_STOP_VIS;
611 }
612 }
613 else if ((LTOREQ_POS(curwin->w_cursor, VIsual)
602 && (LT_POS(m_pos, curwin->w_cursor) 614 && (LT_POS(m_pos, curwin->w_cursor)
603 || LT_POS(VIsual, m_pos))) 615 || LT_POS(VIsual, m_pos)))
604 || (LT_POS(VIsual, curwin->w_cursor) 616 || (LT_POS(VIsual, curwin->w_cursor)
605 && (LT_POS(m_pos, VIsual) 617 && (LT_POS(m_pos, VIsual)
606 || LT_POS(curwin->w_cursor, m_pos)))) 618 || LT_POS(curwin->w_cursor, m_pos))))