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>
diff --git a/src/mouse.c b/src/mouse.c
index e5f0687..af14af0 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -2098,35 +2098,7 @@
redraw_cmdline = TRUE; // show visual mode later
}
- if (col_from_screen == MAXCOL)
- {
- // When clicking after end of line, still need to set correct curswant
- int off_l = LineOffset[prev_row] + curwin->w_wincol;
- if (ScreenCols[off_l] < MAXCOL)
- {
- // Binary search to find last char in line
- int off_r = LineOffset[prev_row] + prev_col;
- int off_click = off_r;
- while (off_l < off_r)
- {
- int off_m = (off_l + off_r + 1) / 2;
- if (ScreenCols[off_m] < MAXCOL)
- off_l = off_m;
- else
- off_r = off_m - 1;
- }
- colnr_T eol_vcol = ScreenCols[off_r];
- if (eol_vcol < 0)
- // Empty line or whole line before w_leftcol,
- // with columns before buffer text
- eol_vcol = curwin->w_leftcol - 1;
- col = eol_vcol + (off_click - off_r);
- }
- else
- // Empty line or whole line before w_leftcol
- col = prev_col - curwin->w_wincol + curwin->w_leftcol;
- }
- else if (col_from_screen >= 0)
+ if (col_from_screen >= 0)
{
// Use the virtual column from ScreenCols[], it is accurate also after
// concealed characters.