summaryrefslogtreecommitdiffstats
path: root/src/mouse.c
diff options
context:
space:
mode:
authorYee Cheng Chin <ychin.git@gmail.com>2022-11-19 14:31:08 +0000
committerBram Moolenaar <Bram@vim.org>2022-11-19 14:31:08 +0000
commite6392b102151ec69fad232bcf00591230cef8e1c (patch)
treee5bf2bd19c97d3ff0b72b95ebd169d5c775f0515 /src/mouse.c
parentc934bfa1b765505e5fc491f2ee7cc106894cafc8 (diff)
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrongv9.0.0911
Problem: With 'smoothscroll' set mouse click position may be wrong. Solution: Adjust computations for w_skipcol. (Yee Cheng Chin, closes #11514)
Diffstat (limited to 'src/mouse.c')
-rw-r--r--src/mouse.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/mouse.c b/src/mouse.c
index 98e05955eb..32407eb394 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -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)