diff src/popupwin.c @ 17196:983950357c40 v8.1.1597

patch 8.1.1597: cannot scroll a popup window with the mouse commit https://github.com/vim/vim/commit/68acb41f990405cb5ccd33fcba71a5d499c82974 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 26 03:40:36 2019 +0200 patch 8.1.1597: cannot scroll a popup window with the mouse Problem: Cannot scroll a popup window with the mouse. Solution: If the popup window has a scrollbar let the mouse scroll wheel scroll the window.
author Bram Moolenaar <Bram@vim.org>
date Wed, 26 Jun 2019 03:45:04 +0200
parents f4c6c1bc5e41
children db81cee3a0e1
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1547,6 +1547,7 @@ f_popup_getpos(typval_T *argvars, typval
 	dict_add_number(dict, "core_height", wp->w_height);
 
 	dict_add_number(dict, "scrollbar", wp->w_has_scrollbar);
+	dict_add_number(dict, "firstline", wp->w_topline);
 	dict_add_number(dict, "visible",
 		      win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0);
     }
@@ -2238,12 +2239,13 @@ update_popups(void (*win_update)(win_T *
 	{
 	    linenr_T linecount = wp->w_buffer->b_ml.ml_line_count;
 
-	    sb_thumb_height = wp->w_height * wp->w_height / linecount;
+	    sb_thumb_height = (wp->w_height * wp->w_height + linecount / 2)
+								   / linecount;
 	    if (sb_thumb_height == 0)
 		sb_thumb_height = 1;
-	    sb_thumb_top = ((wp->w_topline * (wp->w_height - sb_thumb_height)
-			    + (linecount - wp->w_height) / 2))
-			      / (linecount - (wp->w_height - sb_thumb_height));
+	    sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2)
+				* (wp->w_height - sb_thumb_height)
+						  / (linecount - wp->w_height);
 	}
 
 	for (i = wp->w_popup_border[0];