Reset the color before we clear to eol

Fixes https://github.com/fish-shell/fish-shell/issues/493
This commit is contained in:
ridiculousfish 2013-01-04 22:32:40 -08:00
parent edb973fadc
commit 1c83144773
3 changed files with 12 additions and 31 deletions

View file

@ -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 write_loop(int fd, const char *buff, size_t count)
{ {
ssize_t out=0;
size_t out_cum=0; size_t out_cum=0;
while (1) while (out_cum < count)
{ {
out = write(fd, ssize_t out = write(fd, &buff[out_cum], count - out_cum);
&buff[out_cum],
count - out_cum);
if (out < 0) if (out < 0)
{ {
if (errno != EAGAIN && errno != EINTR) 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; out_cum += (size_t)out;
} }
if (out_cum >= count)
{
break;
}
} }
return (ssize_t)out_cum; return (ssize_t)out_cum;
} }

View file

@ -1260,25 +1260,12 @@ static void autosuggest_completed(autosuggestion_context_t *ctx, int result)
static void update_autosuggestion(void) 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. */ /* 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(); data->autosuggestion.clear();
if (data->allow_autosuggestion && ! data->suppress_autosuggestion && ! data->command_line.empty() && data->history_search.is_at_end()) 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); autosuggestion_context_t *ctx = new autosuggestion_context_t(data->history, data->command_line, data->buff_pos);
iothread_perform(threaded_autosuggest, autosuggest_completed, ctx); 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" */ /* 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()) if (! data->search_buff.empty() && ! data->history_search.is_at_end())
{ {
const wchar_t *buff = data->command_line.c_str(); const wcstring &needle = data->search_buff;
const wchar_t *match = wcsstr(buff, data->search_buff.c_str()); size_t match_pos = data->command_line.find(needle);
if (match) if (match_pos != wcstring::npos)
{ {
size_t start = match-buff; size_t end = match_pos + needle.size();
size_t i, count = data->search_buff.size(); for (size_t i=match_pos; i < end; i++)
for (i=0; i<count; i++)
{ {
data->colors.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 Call specified external highlighting function and then do search
highlighting. Lastly, clear the background color under the cursor 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. 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 \param match_highlight_pos the position to use for bracket matching. This need not be the same as the surrent cursor position

View file

@ -973,6 +973,7 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r
} }
if (clear_remainder) if (clear_remainder)
{ {
s_set_color(scr, &output, 0xffffffff);
s_move(scr, &output, current_width, (int)i); s_move(scr, &output, current_width, (int)i);
s_write_mbs(&output, clr_eol); 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. */ /* 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++) for (size_t i=scr->desired.line_count(); i < lines_with_stuff; i++)
{ {
s_move(scr, &output, 0, (int)i); s_move(scr, &output, 0, (int)i);