Skip to content

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