Skip to content

Conversation

@lzybkr
Copy link
Contributor

Instead of changing Console.*groundColor on every character, only set
the color when the color changes - this avoids writing out ANSI escape
sequences after every character.

Fixes#4075

Instead of changing Console.*groundColor on every character, only set the color when the color changes - this avoids writing out ANSI escape sequences after every character. FixesPowerShell#4075
Console.BackgroundColor=buffer[i].BackgroundColor;
varnextForegroundColor=buffer[i].ForegroundColor;
varnextBackgroundColor=buffer[i].BackgroundColor;
if(lastForegroundColor!=nextForegroundColor)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick, but it seems that if (nextForegroundColor != lastForegroundColor) is slightly more correct improving readability

{
Console.ForegroundColor=lastForegroundColor=nextForegroundColor;
}
if(lastBackgroundColor!=nextBackgroundColor)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above


Console.BackgroundColor=backgroundColor;
Console.ForegroundColor=foregroundColor;
if(backgroundColor!=lastBackgroundColor)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much everywhere else you have foreground first, then background. Another nitpick, but I would reorder these two if statements

@lzybkrlzybkr merged commit ff56097 into PowerShell:masterJun 28, 2017
@lzybkrlzybkr deleted the psreadline_less_ansi branch June 28, 2017 06:22
@mirichmomirichmo added this to the 6.0.0-beta.4 milestone Jun 28, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@lzybkr@SteveL-MSFT@msftclas@mirichmo