diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-11-02 20:21:25 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-11-02 20:21:25 +0100 |
commit | f2885d3fb7045d14ae58824e9cb8dea65e4052c4 (patch) | |
tree | be7d6f209b62884cc1a9443a3b4c1cb5b3a55235 /src/popupwin.c | |
parent | 1a577433ac77b74a965476799619ad0fb2676d31 (diff) | |
download | vim-git-f2885d3fb7045d14ae58824e9cb8dea65e4052c4.tar.gz |
patch 8.1.2240: popup window width changes when scrollingv8.1.2240
Problem: Popup window width changes when scrolling.
Solution: Also adjust maxwidth when applying minwidth and there is a
scrollbar. Fix off-by-one error. (closes #5162)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r-- | src/popupwin.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 212076bae..d6e620760 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -1201,6 +1201,7 @@ popup_adjust_position(win_T *wp) allow_adjust_left = FALSE; maxwidth = wp->w_maxwidth; } + minwidth = wp->w_minwidth; // start at the desired first line if (wp->w_firstline > 0) @@ -1270,18 +1271,19 @@ popup_adjust_position(win_T *wp) if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth) wp->w_width = wp->w_maxwidth; } + + if (wp->w_firstline < 0) + --lnum; + else + ++lnum; + // do not use the width of lines we're not going to show if (wp->w_maxheight > 0 && (wp->w_firstline >= 0 ? lnum - wp->w_topline : wp->w_buffer->b_ml.ml_line_count - lnum) - + 1 + wrapped > wp->w_maxheight) + + wrapped >= wp->w_maxheight) break; - - if (wp->w_firstline < 0) - --lnum; - else - ++lnum; } if (wp->w_firstline < 0) @@ -1293,11 +1295,13 @@ popup_adjust_position(win_T *wp) { ++right_extra; ++extra_width; - if (used_maxwidth) - maxwidth -= 2; // try to show the scrollbar + // make space for the scrollbar if needed, when lines wrap and when + // applying minwidth + if (maxwidth + right_extra >= maxspace + && (used_maxwidth || (minwidth > 0 && wp->w_width < minwidth))) + maxwidth -= wp->w_popup_padding[1] + 1; } - minwidth = wp->w_minwidth; if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL) { int title_len = vim_strsize(wp->w_popup_title) + 2 - extra_width; |