From 1c831447739c560416d5bd466a41649122166a09 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 4 Jan 2013 22:32:40 -0800 Subject: [PATCH] Reset the color before we clear to eol Fixes https://github.com/fish-shell/fish-shell/issues/493 --- common.cpp | 11 ++--------- reader.cpp | 28 +++++++--------------------- screen.cpp | 4 +++- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/common.cpp b/common.cpp index 1a315668b..352074e78 100644 --- a/common.cpp +++ b/common.cpp @@ -634,13 +634,10 @@ long read_blocked(int fd, void *buf, size_t count) ssize_t write_loop(int fd, const char *buff, size_t count) { - ssize_t out=0; size_t out_cum=0; - while (1) + while (out_cum < count) { - out = write(fd, - &buff[out_cum], - count - out_cum); + ssize_t out = write(fd, &buff[out_cum], count - out_cum); if (out < 0) { if (errno != EAGAIN && errno != EINTR) @@ -652,10 +649,6 @@ ssize_t write_loop(int fd, const char *buff, size_t count) { out_cum += (size_t)out; } - if (out_cum >= count) - { - break; - } } return (ssize_t)out_cum; } diff --git a/reader.cpp b/reader.cpp index 592943395..229254b5a 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1260,25 +1260,12 @@ static void autosuggest_completed(autosuggestion_context_t *ctx, int result) static void update_autosuggestion(void) { /* Updates autosuggestion. We look for an autosuggestion if the command line is non-empty and if we're not doing a history search. */ -#if 0 - /* Old non-threaded mode */ - data->autosuggestion.clear(); - if (can_autosuggest()) - { - history_search_t searcher = history_search_t(*data->history, data->command_line, HISTORY_SEARCH_TYPE_PREFIX); - if (searcher.go_backwards()) - { - data->autosuggestion = searcher.current_item().str(); - } - } -#else data->autosuggestion.clear(); if (data->allow_autosuggestion && ! data->suppress_autosuggestion && ! data->command_line.empty() && data->history_search.is_at_end()) { autosuggestion_context_t *ctx = new autosuggestion_context_t(data->history, data->command_line, data->buff_pos); iothread_perform(threaded_autosuggest, autosuggest_completed, ctx); } -#endif } /* Accept any autosuggestion by replacing the command line with it. If full is true, take the whole thing; if it's false, then take only the first "word" */ @@ -2421,15 +2408,14 @@ static void highlight_search(void) { if (! data->search_buff.empty() && ! data->history_search.is_at_end()) { - const wchar_t *buff = data->command_line.c_str(); - const wchar_t *match = wcsstr(buff, data->search_buff.c_str()); - if (match) + const wcstring &needle = data->search_buff; + size_t match_pos = data->command_line.find(needle); + if (match_pos != wcstring::npos) { - size_t start = match-buff; - size_t i, count = data->search_buff.size(); - for (i=0; icolors.at(start+i) |= HIGHLIGHT_SEARCH_MATCH<<16; + data->colors.at(i) |= (HIGHLIGHT_SEARCH_MATCH<<16); } } } @@ -2464,7 +2450,7 @@ static int threaded_highlight(background_highlight_context_t *ctx) /** Call specified external highlighting function and then do search highlighting. Lastly, clear the background color under the cursor - to avoid repaint issues on terminals where e.g. syntax highligthing + to avoid repaint issues on terminals where e.g. syntax highlighting maykes characters under the sursor unreadable. \param match_highlight_pos the position to use for bracket matching. This need not be the same as the surrent cursor position diff --git a/screen.cpp b/screen.cpp index d805b7e69..be2f0203e 100644 --- a/screen.cpp +++ b/screen.cpp @@ -973,6 +973,7 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r } if (clear_remainder) { + s_set_color(scr, &output, 0xffffffff); s_move(scr, &output, current_width, (int)i); s_write_mbs(&output, clr_eol); } @@ -998,8 +999,9 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r /* Clear remaining lines (if any) if we haven't cleared the screen. */ - if (! has_cleared_screen) + if (! has_cleared_screen && scr->desired.line_count() < lines_with_stuff) { + s_set_color(scr, &output, 0xffffffff); for (size_t i=scr->desired.line_count(); i < lines_with_stuff; i++) { s_move(scr, &output, 0, (int)i);