mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-08 23:29:53 +01:00
console colour: fix unintended colouring of user's stderr on POSIX
At some places, the colour reset code is printed after a newline. Since the default output buffering to console is line-based, the reset code is not actually written out. If messages from user code are printed to stderr (different stream, same console), they are printed before the colour reset code, and thus they are coloured. Explicitly flushing the stream after writing the colour escape code solves this.
This commit is contained in:
parent
2d4f8ac8e6
commit
8851e779cf
@ -157,8 +157,10 @@ namespace {
|
||||
|
||||
private:
|
||||
void setColour( const char* _escapeCode ) {
|
||||
// The escape sequence must be flushed to console, otherwise if
|
||||
// stdin and stderr are intermixed, we'd get accidentally coloured output.
|
||||
getCurrentContext().getConfig()->stream()
|
||||
<< '\033' << _escapeCode;
|
||||
<< '\033' << _escapeCode << std::flush;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user