0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal

Problem:    No redraw when leaving terminal-normal mode in a terminal popup
            window.
Solution:   Redraw the popup window. (closes #5708)
This commit is contained in:
Bram Moolenaar
2020-02-28 22:20:10 +01:00
parent 80ae880f5f
commit e52e0c89d1
10 changed files with 126 additions and 34 deletions

View File

@@ -1795,6 +1795,27 @@ update_snapshot(term_T *term)
#endif
}
/*
* Loop over all windows in the current tab, and also curwin, which is not
* encountered when using a terminal in a popup window.
* Return TRUE if "*wp" was set to the next window.
*/
static int
for_all_windows_and_curwin(win_T **wp, int *did_curwin)
{
if (*wp == NULL)
*wp = firstwin;
else if ((*wp)->w_next != NULL)
*wp = (*wp)->w_next;
else if (!*did_curwin)
*wp = curwin;
else
return FALSE;
if (*wp == curwin)
*did_curwin = TRUE;
return TRUE;
}
/*
* If needed, add the current lines of the terminal to scrollback and to the
* buffer. Called after the job has ended and when switching to
@@ -1804,8 +1825,6 @@ update_snapshot(term_T *term)
static void
may_move_terminal_to_buffer(term_T *term, int redraw)
{
win_T *wp;
if (term->tl_vterm == NULL)
return;
@@ -1820,7 +1839,11 @@ may_move_terminal_to_buffer(term_T *term, int redraw)
&term->tl_default_color.fg, &term->tl_default_color.bg);
if (redraw)
FOR_ALL_WINDOWS(wp)
{
win_T *wp = NULL;
int did_curwin = FALSE;
while (for_all_windows_and_curwin(&wp, &did_curwin))
{
if (wp->w_buffer == term->tl_buffer)
{
@@ -1837,6 +1860,7 @@ may_move_terminal_to_buffer(term_T *term, int redraw)
redraw_win_later(wp, NOT_VALID);
}
}
}
}
#if defined(FEAT_TIMERS) || defined(PROTO)
@@ -1920,6 +1944,7 @@ term_enter_normal_mode(void)
check_cursor();
if (coladvance(term->tl_cursor_pos.col) == FAIL)
coladvance(MAXCOL);
curwin->w_set_curswant = TRUE;
// Display the same lines as in the terminal.
curwin->w_topline = term->tl_scrollback_scrolled + 1;
@@ -1951,6 +1976,10 @@ term_enter_job_mode()
if (term->tl_channel_closed)
cleanup_vterm(term);
redraw_buf_and_status_later(curbuf, NOT_VALID);
#ifdef FEAT_PROP_POPUP
if (WIN_IS_POPUP(curwin))
redraw_win_later(curwin, NOT_VALID);
#endif
}
/*
@@ -2801,14 +2830,15 @@ handle_damage(VTermRect rect, void *user)
static void
term_scroll_up(term_T *term, int start_row, int count)
{
win_T *wp;
win_T *wp = NULL;
int did_curwin = FALSE;
VTermColor fg, bg;
VTermScreenCellAttrs attr;
int clear_attr;
vim_memset(&attr, 0, sizeof(attr));
FOR_ALL_WINDOWS(wp)
while (for_all_windows_and_curwin(&wp, &did_curwin))
{
if (wp->w_buffer == term->tl_buffer)
{
@@ -2858,12 +2888,13 @@ handle_movecursor(
void *user)
{
term_T *term = (term_T *)user;
win_T *wp;
win_T *wp = NULL;
int did_curwin = FALSE;
term->tl_cursor_pos = pos;
term->tl_cursor_visible = visible;
FOR_ALL_WINDOWS(wp)
while (for_all_windows_and_curwin(&wp, &did_curwin))
{
if (wp->w_buffer == term->tl_buffer)
position_cursor(wp, &pos, FALSE);