From 9b60af4d52e312af78b7156d1d74fa8320bf0d62 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Wed, 3 Oct 2012 12:19:27 -0700 Subject: [PATCH] Fix to propagate the last color before highlighting completes, and to avoid repainting when highlighting completes if the color does not change --- reader.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/reader.cpp b/reader.cpp index a580754e0..50540ee8a 100644 --- a/reader.cpp +++ b/reader.cpp @@ -542,7 +542,11 @@ void reader_pop_current_filename() void reader_data_t::command_line_changed() { ASSERT_IS_MAIN_THREAD(); size_t len = command_length(); - colors.resize(len); + + /* When we grow colors, propagate the last color (if any), under the assumption that usually it will be correct. If it is, it avoids a repaint. */ + color_t last_color = colors.empty() ? color_t() : colors.back(); + colors.resize(len, last_color); + indents.resize(len); /* Update the gen count */ @@ -2314,17 +2318,19 @@ static void highlight_search(void) { static void highlight_complete(background_highlight_context_t *ctx, int result) { ASSERT_IS_MAIN_THREAD(); if (ctx->string_to_highlight == data->command_line) { - /* The data hasn't changed, so swap in our colors */ + /* The data hasn't changed, so swap in our colors. The colors may not have changed, so do nothing if they have not. */ assert(ctx->colors.size() == data->command_length()); - data->colors.swap(ctx->colors); - - - //data->repaint_needed = 1; - //s_reset( &data->screen, 1 ); - - sanity_check(); - highlight_search(); - reader_repaint(); + if (data->colors != ctx->colors) + { + data->colors.swap(ctx->colors); + + //data->repaint_needed = 1; + //s_reset( &data->screen, 1 ); + + sanity_check(); + highlight_search(); + reader_repaint(); + } } /* Free our context */