diff options
Diffstat (limited to 'src/gtest.cc')
-rw-r--r-- | src/gtest.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gtest.cc b/src/gtest.cc index f5de645b..fb5bae94 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -2631,13 +2631,15 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); const WORD old_color_attrs = buffer_info.wAttributes; + // We need to flush the stream buffers into the console before each + // SetConsoleTextAttribute call lest it affect the text that is already + // printed but has not yet reached the console. + fflush(stdout); SetConsoleTextAttribute(stdout_handle, GetColorAttribute(color) | FOREGROUND_INTENSITY); vprintf(fmt, args); - // Unless we flush stream buffers now the next SetConsoleTextAttribute - // call can reset the color before the output reaches the console. - fflush(stdout); + fflush(stdout); // Restores the text color. SetConsoleTextAttribute(stdout_handle, old_color_attrs); #else |