forked from aniani/vim
patch 8.0.1830: switching to Terminal-Normal mode does not redraw
Problem: Switching to Terminal-Normal mode does not redraw. (Dominique Pelle) Solution: Also redraw when not updating the snapshot. (closes #2904)
This commit is contained in:
parent
12365ce49f
commit
05c4a471d2
@ -1479,28 +1479,17 @@ cleanup_scrollback(term_T *term)
|
||||
|
||||
/*
|
||||
* Add the current lines of the terminal to scrollback and to the buffer.
|
||||
* Called after the job has ended and when switching to Terminal-Normal mode.
|
||||
*/
|
||||
static void
|
||||
move_terminal_to_buffer(term_T *term)
|
||||
update_snapshot(term_T *term)
|
||||
{
|
||||
win_T *wp;
|
||||
VTermScreen *screen;
|
||||
int len;
|
||||
int lines_skipped = 0;
|
||||
VTermPos pos;
|
||||
VTermScreenCell cell;
|
||||
cellattr_T fill_attr, new_fill_attr;
|
||||
cellattr_T *p;
|
||||
VTermScreen *screen;
|
||||
|
||||
if (term->tl_vterm == NULL)
|
||||
return;
|
||||
|
||||
/* Nothing to do if the buffer already has the lines and nothing was
|
||||
* changed. */
|
||||
if (!term->tl_dirty_snapshot && term->tl_buffer->b_ml.ml_line_count
|
||||
> term->tl_scrollback_scrolled)
|
||||
return;
|
||||
|
||||
ch_log(term->tl_job == NULL ? NULL : term->tl_job->jv_channel,
|
||||
"Adding terminal window snapshot to buffer");
|
||||
@ -1601,12 +1590,33 @@ move_terminal_to_buffer(term_T *term)
|
||||
#ifdef FEAT_TIMERS
|
||||
term->tl_timer_set = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
* Terminal-Normal mode.
|
||||
* When "redraw" is TRUE redraw the windows that show the terminal.
|
||||
*/
|
||||
static void
|
||||
may_move_terminal_to_buffer(term_T *term, int redraw)
|
||||
{
|
||||
win_T *wp;
|
||||
|
||||
if (term->tl_vterm == NULL)
|
||||
return;
|
||||
|
||||
/* Update the snapshot only if something changes or the buffer does not
|
||||
* have all the lines. */
|
||||
if (term->tl_dirty_snapshot || term->tl_buffer->b_ml.ml_line_count
|
||||
<= term->tl_scrollback_scrolled)
|
||||
update_snapshot(term);
|
||||
|
||||
/* Obtain the current background color. */
|
||||
vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
|
||||
&term->tl_default_color.fg, &term->tl_default_color.bg);
|
||||
|
||||
if (term->tl_normal_mode)
|
||||
if (redraw)
|
||||
FOR_ALL_WINDOWS(wp)
|
||||
{
|
||||
if (wp->w_buffer == term->tl_buffer)
|
||||
@ -1647,7 +1657,7 @@ term_check_timers(int next_due_arg, proftime_T *now)
|
||||
if (this_due <= 1)
|
||||
{
|
||||
term->tl_timer_set = FALSE;
|
||||
move_terminal_to_buffer(term);
|
||||
may_move_terminal_to_buffer(term, FALSE);
|
||||
}
|
||||
else if (next_due == -1 || next_due > this_due)
|
||||
next_due = this_due;
|
||||
@ -1675,7 +1685,7 @@ set_terminal_mode(term_T *term, int normal_mode)
|
||||
cleanup_vterm(term_T *term)
|
||||
{
|
||||
if (term->tl_finish != TL_FINISH_CLOSE)
|
||||
move_terminal_to_buffer(term);
|
||||
may_move_terminal_to_buffer(term, TRUE);
|
||||
term_free_vterm(term);
|
||||
set_terminal_mode(term, FALSE);
|
||||
}
|
||||
@ -1692,7 +1702,7 @@ term_enter_normal_mode(void)
|
||||
set_terminal_mode(term, TRUE);
|
||||
|
||||
/* Append the current terminal contents to the buffer. */
|
||||
move_terminal_to_buffer(term);
|
||||
may_move_terminal_to_buffer(term, TRUE);
|
||||
|
||||
/* Move the window cursor to the position of the cursor in the
|
||||
* terminal. */
|
||||
@ -2255,7 +2265,8 @@ theend:
|
||||
/* Move a snapshot of the screen contents to the buffer, so that completion
|
||||
* works in other buffers. */
|
||||
if (curbuf->b_term != NULL)
|
||||
move_terminal_to_buffer(curbuf->b_term);
|
||||
may_move_terminal_to_buffer(
|
||||
curbuf->b_term, curbuf->b_term->tl_normal_mode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -761,6 +761,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1830,
|
||||
/**/
|
||||
1829,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user