Problem: Crash when popup has fitting scrollbar. (Trygve Aaberge)
Solution: Don't divide by zero if the scrollbar just fits. (closes #4615)
/ linecount;
if (sb_thumb_height == 0)
sb_thumb_height = 1;
- sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2)
+ if (linecount <= wp->w_height)
+ // it just fits, avoid divide by zero
+ sb_thumb_top = 0;
+ else
+ sb_thumb_top = (wp->w_topline - 1
+ + (linecount / wp->w_height) / 2)
* (wp->w_height - sb_thumb_height)
/ (linecount - wp->w_height);
if (wp->w_scrollbar_highlight != NULL)
call delete('XtestPopupScroll')
endfunc
+func Test_popup_fitting_scrollbar()
+ " this was causing a crash, divide by zero
+ let winid = popup_create([
+ \ 'one', 'two', 'longer line that wraps', 'four', 'five'], {
+ \ 'scrollbar': 1,
+ \ 'maxwidth': 10,
+ \ 'maxheight': 5,
+ \ 'firstline': 2})
+ redraw
+ call popup_clear()
+endfunc
+
func Test_popup_settext()
if !CanRunVimInTerminal()
throw 'Skipped: cannot make screendumps'
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1636,
/**/
1635,
/**/