diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-10 20:39:17 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-10 20:39:17 +0200 |
commit | bf61fdd00808bfa7cc61a82c719fc220bba50ba3 (patch) | |
tree | 5e4042bff70ac9709c1984285952bc6a6c643b25 /src/popupwin.c | |
parent | 94f4ffa7704921a3634e56b878e6dc362bc3d508 (diff) | |
download | vim-git-bf61fdd00808bfa7cc61a82c719fc220bba50ba3.tar.gz |
patch 8.2.1414: popupwindow missing last couple of linesv8.2.1414
Problem: Popupwindow missing last couple of lines when cursor is in the
first line.
Solution: Compute the max height also when top aligned. (closes #6664)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r-- | src/popupwin.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 5325bf6f1..cc0843bfc 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -1134,6 +1134,7 @@ popup_adjust_position(win_T *wp) int wantline = wp->w_wantline; // adjusted for textprop int wantcol = wp->w_wantcol; // adjusted for textprop int use_wantcol = wantcol != 0; + int adjust_height_for_top_aligned = FALSE; wp->w_winrow = 0; wp->w_wincol = 0; @@ -1483,16 +1484,7 @@ popup_adjust_position(win_T *wp) // Not enough space and more space on the other side: make top // aligned. wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1; - if (wp->w_winrow + wp->w_height + extra_height >= Rows) - { - wp->w_height = Rows - wp->w_winrow - extra_height; - if (wp->w_want_scrollbar -#ifdef FEAT_TERMINAL - && wp->w_buffer->b_term == NULL -#endif - ) - wp->w_has_scrollbar = TRUE; - } + adjust_height_for_top_aligned = TRUE; } } else if (wp->w_popup_pos == POPPOS_TOPRIGHT @@ -1513,9 +1505,25 @@ popup_adjust_position(win_T *wp) } } else + { wp->w_winrow = wantline - 1; + adjust_height_for_top_aligned = TRUE; + } } - // make sure w_window is valid + + if (adjust_height_for_top_aligned && wp->w_want_scrollbar + && wp->w_winrow + wp->w_height + extra_height > Rows) + { + // Bottom of the popup goes below the last line, reduce the height and + // add a scrollbar. + wp->w_height = Rows - wp->w_winrow - extra_height; +#ifdef FEAT_TERMINAL + if (wp->w_buffer->b_term == NULL) +#endif + wp->w_has_scrollbar = TRUE; + } + + // make sure w_winrow is valid if (wp->w_winrow >= Rows) wp->w_winrow = Rows - 1; else if (wp->w_winrow < 0) |