0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong

Problem:    With 'smoothscroll' set mouse click position may be wrong.
Solution:   Adjust computations for w_skipcol. (Yee Cheng Chin, closes #11514)
This commit is contained in:
Yee Cheng Chin
2022-11-19 14:31:08 +00:00
committed by Bram Moolenaar
parent c934bfa1b7
commit e6392b1021
3 changed files with 84 additions and 4 deletions

View File

@@ -3034,14 +3034,29 @@ mouse_comp_pos(
row -= win->w_topfill;
else
row -= diff_check_fill(win, lnum);
count = plines_win_nofill(win, lnum, TRUE);
count = plines_win_nofill(win, lnum, FALSE);
}
else
#endif
count = plines_win(win, lnum, TRUE);
count = plines_win(win, lnum, FALSE);
if (plines_cache != NULL && cache_idx < Rows)
plines_cache[cache_idx] = count;
}
if (win->w_skipcol > 0 && lnum == win->w_topline)
{
// Adjust for 'smoothscroll' clipping the top screen lines.
// A similar formula is used in curs_columns().
int width1 = win->w_width - win_col_off(win);
int skip_lines = 0;
if (win->w_skipcol > width1)
skip_lines = (win->w_skipcol - width1)
/ (width1 + win_col_off2(win)) + 1;
else if (win->w_skipcol > 0)
skip_lines = 1;
count -= skip_lines;
}
if (count > row)
break; // Position is in this buffer line.
#ifdef FEAT_FOLDING
@@ -3063,8 +3078,10 @@ mouse_comp_pos(
if (col < off)
col = off;
col += row * (win->w_width - off);
// add skip column (for long wrapping line)
col += win->w_skipcol;
// Add skip column for the topline.
if (lnum == win->w_topline)
col += win->w_skipcol;
}
if (!win->w_p_wrap)