Mercurial > vim
comparison src/popupwin.c @ 18074:364a9be6a21e v8.1.2032
patch 8.1.2032: scrollbar thumb wrong in popup window
Commit: https://github.com/vim/vim/commit/076d98839c4f6f15ae3563263057aa99ff04a869
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 14 22:23:29 2019 +0200
patch 8.1.2032: scrollbar thumb wrong in popup window
Problem: Scrollbar thumb wrong in popup window.
Solution: Adjust thumb size and position when scrolled.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 Sep 2019 22:30:03 +0200 |
parents | 56032a704448 |
children | 9c3347b21b89 |
comparison
equal
deleted
inserted
replaced
18073:c53b2d988211 | 18074:364a9be6a21e |
---|---|
3361 } | 3361 } |
3362 | 3362 |
3363 // Compute scrollbar thumb position and size. | 3363 // Compute scrollbar thumb position and size. |
3364 if (wp->w_has_scrollbar) | 3364 if (wp->w_has_scrollbar) |
3365 { | 3365 { |
3366 linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; | 3366 linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; |
3367 | 3367 int height = wp->w_height; |
3368 sb_thumb_height = (wp->w_height * wp->w_height + linecount / 2) | 3368 |
3369 / linecount; | 3369 sb_thumb_height = (height * height + linecount / 2) / linecount; |
3370 if (wp->w_topline > 1 && sb_thumb_height == height) | |
3371 --sb_thumb_height; // scrolled, no full thumb | |
3370 if (sb_thumb_height == 0) | 3372 if (sb_thumb_height == 0) |
3371 sb_thumb_height = 1; | 3373 sb_thumb_height = 1; |
3372 if (linecount <= wp->w_height) | 3374 if (linecount <= wp->w_height) |
3373 // it just fits, avoid divide by zero | 3375 // it just fits, avoid divide by zero |
3374 sb_thumb_top = 0; | 3376 sb_thumb_top = 0; |
3375 else | 3377 else |
3376 sb_thumb_top = (wp->w_topline - 1 | 3378 sb_thumb_top = (wp->w_topline - 1 |
3377 + (linecount / wp->w_height) / 2) | 3379 + (linecount / wp->w_height) / 2) |
3378 * (wp->w_height - sb_thumb_height) | 3380 * (wp->w_height - sb_thumb_height) |
3379 / (linecount - wp->w_height); | 3381 / (linecount - wp->w_height); |
3382 if (wp->w_topline > 1 && sb_thumb_top == 0 && height > 1) | |
3383 sb_thumb_top = 1; // show it's scrolled | |
3384 | |
3380 if (wp->w_scrollbar_highlight != NULL) | 3385 if (wp->w_scrollbar_highlight != NULL) |
3381 attr_scroll = syn_name2attr(wp->w_scrollbar_highlight); | 3386 attr_scroll = syn_name2attr(wp->w_scrollbar_highlight); |
3382 else | 3387 else |
3383 attr_scroll = highlight_attr[HLF_PSB]; | 3388 attr_scroll = highlight_attr[HLF_PSB]; |
3384 if (wp->w_thumb_highlight != NULL) | 3389 if (wp->w_thumb_highlight != NULL) |