Skip to content

Reset the terminal color before the newline for diagnostics #14296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2014

Conversation

lilyball
Copy link
Contributor

When printing colored diagnostics, we need to reset the terminal before
emitting the newline, not after. Otherwise it gets line-buffered and the
color won't reset until the next line is printed or the compiler exits.

Normally this isn't a problem, but when running rustc in parallel with
other processes (e.g. make -j4) this can cause the color to leak
to other lines.

@alexcrichton
Copy link
Member

The comment may be a little misleading as it sounds like this is a guaranteed fix for the problem. It actually relies on the underlying writer being line buffered as well as the message itself not containing any newlines. These assumptions are true 95% of the time, but I think they should be reflected in the comment.

r=me with the comment adjustment.

When printing colored diagnostics, we need to reset the terminal before
emitting the newline, not after. Otherwise it gets line-buffered and the
color won't reset until the next line is printed or the compiler exits.

Normally this isn't a problem, but when running rustc in parallel with
other processes (e.g. `make -j4`) this can cause the color to leak
to other lines.
bors added a commit that referenced this pull request May 20, 2014
…crichton

When printing colored diagnostics, we need to reset the terminal before
emitting the newline, not after. Otherwise it gets line-buffered and the
color won't reset until the next line is printed or the compiler exits.

Normally this isn't a problem, but when running rustc in parallel with
other processes (e.g. `make -j4`) this can cause the color to leak
to other lines.
@bors bors closed this May 20, 2014
@bors bors merged commit b991bbe into rust-lang:master May 20, 2014
@lilyball lilyball deleted the diagnostic_color_newline branch May 20, 2014 16:53
Sign up for free to 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.

3 participants