1
0
forked from aniani/vim

patch 8.2.5038: a finished terminal in a popup window does not show scrollbar

Problem:    A finished terminal in a popup window does not show a scrollbar.
Solution:   Show the scrollbar if the terminal job is finished. (closes
            #10497)
This commit is contained in:
Bram Moolenaar
2022-05-29 14:13:04 +01:00
parent 4d97a565ae
commit d28950f954
6 changed files with 108 additions and 10 deletions

View File

@@ -375,22 +375,36 @@ popup_is_in_scrollbar(win_T *wp, int row, int col)
void
popup_handle_scrollbar_click(win_T *wp, int row, int col)
{
int height = popup_height(wp);
int old_topline = wp->w_topline;
if (popup_is_in_scrollbar(wp, row, col))
{
int height = popup_height(wp);
int new_topline = wp->w_topline;
if (row >= height / 2)
{
// Click in lower half, scroll down.
if (wp->w_topline < wp->w_buffer->b_ml.ml_line_count)
++wp->w_topline;
++new_topline;
}
else if (wp->w_topline > 1)
// click on upper half, scroll up.
--wp->w_topline;
if (wp->w_topline != old_topline)
--new_topline;
if (new_topline != wp->w_topline)
{
set_topline(wp, new_topline);
if (wp == curwin)
{
if (wp->w_cursor.lnum < wp->w_topline)
{
wp->w_cursor.lnum = wp->w_topline;
check_cursor();
}
else if (wp->w_cursor.lnum >= wp->w_botline)
{
wp->w_cursor.lnum = wp->w_botline - 1;
check_cursor();
}
}
popup_set_firstline(wp);
redraw_win_later(wp, NOT_VALID);
}
@@ -1419,8 +1433,9 @@ popup_adjust_position(win_T *wp)
wp->w_has_scrollbar = wp->w_want_scrollbar
&& (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count);
#ifdef FEAT_TERMINAL
if (wp->w_buffer->b_term != NULL)
// Terminal window never has a scrollbar, adjusts to window height.
if (wp->w_buffer->b_term != NULL && !term_is_finished(wp->w_buffer))
// Terminal window with running job never has a scrollbar, adjusts to
// window height.
wp->w_has_scrollbar = FALSE;
#endif
maxwidth_no_scrollbar = maxwidth;
@@ -1587,7 +1602,7 @@ popup_adjust_position(win_T *wp)
// add a scrollbar.
wp->w_height = Rows - wp->w_winrow - extra_height;
#ifdef FEAT_TERMINAL
if (wp->w_buffer->b_term == NULL)
if (wp->w_buffer->b_term == NULL || term_is_finished(wp->w_buffer))
#endif
{
wp->w_has_scrollbar = TRUE;