mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
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>
This commit is contained in:
committed by
Christian Brabandt
parent
9e7f1fc2f1
commit
d0c1b7723f
30
src/mouse.c
30
src/mouse.c
@@ -2098,35 +2098,7 @@ retnomove:
|
||||
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.
|
||||
|
Reference in New Issue
Block a user