terminal: Avoid unnecessary redraws.

This commit is contained in:
Justin M. Keyes 2017-02-28 15:14:20 +01:00
parent 857113ca8c
commit 3aedf9d669

View File

@ -1003,9 +1003,12 @@ static void refresh_timer_cb(TimeWatcher *watcher, void *data)
map_foreach(invalidated_terminals, term, stub, {
refresh_terminal(term);
});
bool any_visible = is_term_visible();
pmap_clear(ptr_t)(invalidated_terminals);
unblock_autocmds();
redraw(true);
if (any_visible) {
redraw(true);
}
end:
refresh_pending = false;
}
@ -1119,6 +1122,18 @@ static void refresh_screen(Terminal *term, buf_T *buf)
term->invalid_end = -1;
}
/// @return true if any invalidated terminal buffer is visible to the user
static bool is_term_visible(void)
{
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_buffer->terminal
&& pmap_has(ptr_t)(invalidated_terminals, wp->w_buffer->terminal)) {
return true;
}
}
return false;
}
static void redraw(bool restore_cursor)
{
Terminal *term = curbuf->terminal;