comparison src/mouse.c @ 34571:fdd232ab72ea v9.1.0184

patch 9.1.0184: Cursor pos wrong when clicking with conceal and wrap Commit: https://github.com/vim/vim/commit/d0c1b7723f7e73763597af2f97a53d94ab7ed020 Author: zeertzjq <zeertzjq@outlook.com> Date: Sat Mar 16 15:03:33 2024 +0100 patch 9.1.0184: Cursor pos wrong when clicking with conceal and wrap Problem: Cursor position wrong when clicking with conceal and wrap. Solution: Use the virtual column of the last char for ScreenCols[] in boguscols. Remove use of MAXCOL in ScreenCols[]. Rename third argument of wlv_screen_line() to "clear_end" as that's clearer what it does (zeertzjq). related: 14192 closes: #14200 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Mar 2024 15:15:04 +0100
parents 7f84a834055a
children ca2da8e8fb53
comparison
equal deleted inserted replaced
34570:68553f944407 34571:fdd232ab72ea
2096 setmouse(); 2096 setmouse();
2097 if (p_smd && msg_silent == 0) 2097 if (p_smd && msg_silent == 0)
2098 redraw_cmdline = TRUE; // show visual mode later 2098 redraw_cmdline = TRUE; // show visual mode later
2099 } 2099 }
2100 2100
2101 if (col_from_screen == MAXCOL) 2101 if (col_from_screen >= 0)
2102 {
2103 // When clicking after end of line, still need to set correct curswant
2104 int off_l = LineOffset[prev_row] + curwin->w_wincol;
2105 if (ScreenCols[off_l] < MAXCOL)
2106 {
2107 // Binary search to find last char in line
2108 int off_r = LineOffset[prev_row] + prev_col;
2109 int off_click = off_r;
2110 while (off_l < off_r)
2111 {
2112 int off_m = (off_l + off_r + 1) / 2;
2113 if (ScreenCols[off_m] < MAXCOL)
2114 off_l = off_m;
2115 else
2116 off_r = off_m - 1;
2117 }
2118 colnr_T eol_vcol = ScreenCols[off_r];
2119 if (eol_vcol < 0)
2120 // Empty line or whole line before w_leftcol,
2121 // with columns before buffer text
2122 eol_vcol = curwin->w_leftcol - 1;
2123 col = eol_vcol + (off_click - off_r);
2124 }
2125 else
2126 // Empty line or whole line before w_leftcol
2127 col = prev_col - curwin->w_wincol + curwin->w_leftcol;
2128 }
2129 else if (col_from_screen >= 0)
2130 { 2102 {
2131 // Use the virtual column from ScreenCols[], it is accurate also after 2103 // Use the virtual column from ScreenCols[], it is accurate also after
2132 // concealed characters. 2104 // concealed characters.
2133 col = col_from_screen; 2105 col = col_from_screen;
2134 } 2106 }