aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-04-28 03:59:53 +0200
committerLuuk van Baal <luukvbaal@gmail.com>2023-05-02 13:11:47 +0200
commit5ba11087b60eb7cbcaa1ea4ccbb0b1a6bcf3c1be (patch)
tree6c06848017e3b4a991142fb0f09244af030e11e6 /src/nvim
parent46646a9bb81b72d5579beade64006d6f3dc64d19 (diff)
downloadrneovim-5ba11087b60eb7cbcaa1ea4ccbb0b1a6bcf3c1be.tar.gz
rneovim-5ba11087b60eb7cbcaa1ea4ccbb0b1a6bcf3c1be.tar.bz2
rneovim-5ba11087b60eb7cbcaa1ea4ccbb0b1a6bcf3c1be.zip
vim-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 vim/vim#11514) https://github.com/vim/vim/commit/e6392b102151ec69fad232bcf00591230cef8e1c Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/mouse.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index ead8dc2195..b890727a98 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -1410,9 +1410,22 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
} else {
row -= win_get_fill(win, lnum);
}
- count = plines_win_nofill(win, lnum, true);
+ count = plines_win_nofill(win, lnum, false);
} else {
- count = plines_win(win, lnum, true);
+ count = plines_win(win, lnum, false);
+ }
+
+ 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) {
@@ -1436,8 +1449,11 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
col = off;
}
col += row * (win->w_width_inner - 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) {