Mercurial > vim
changeset 13919:bfca3dbdbf9e v8.0.1830
patch 8.0.1830: switching to Terminal-Normal mode does not redraw
commit https://github.com/vim/vim/commit/05c4a471d235987b914a9cc3ca44b98c46abd157
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 13 15:15:43 2018 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 13 May 2018 15:30:06 +0200 |
parents | 9cef228c53d6 |
children | ceb452a8cfd8 |
files | src/terminal.c src/version.c |
diffstat | 2 files changed, 31 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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, prof 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 norm 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; }