summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-05-13 15:15:43 +0200
committerBram Moolenaar <Bram@vim.org>2018-05-13 15:15:43 +0200
commit05c4a471d235987b914a9cc3ca44b98c46abd157 (patch)
tree1f4d870bd6c4173423a5b40c2c81987799b5bbbb
parent12365ce49f671a62a1e647df205c9a020828ee1b (diff)
downloadvim-git-8.0.1830.tar.gz
patch 8.0.1830: switching to Terminal-Normal mode does not redrawv8.0.1830
Problem: Switching to Terminal-Normal mode does not redraw. (Dominique Pelle) Solution: Also redraw when not updating the snapshot. (closes #2904)
-rw-r--r--src/terminal.c47
-rw-r--r--src/version.c2
2 files changed, 31 insertions, 18 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 21ef870de..e670161fb 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -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;
}
diff --git a/src/version.c b/src/version.c
index 555275b76..3a3987c44 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1830,
+/**/
1829,
/**/
1828,