Skip to content

Commit b66a57b

Browse files
add buffer flush before direct write
1 parent 5c4fc70 commit b66a57b

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

include/fmt/format-inl.h

+1
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,7 @@ extern "C" __declspec(dllimport) int __stdcall WriteConsoleW( //
14351435
FMT_FUNC bool write_console(std::FILE* f, string_view text) {
14361436
int fd = _fileno(f);
14371437
if (!_isatty(fd)) return false;
1438+
std::fflush(f);
14381439
auto u16 = utf8_to_utf16(text);
14391440
return WriteConsoleW(reinterpret_cast<void*>(_get_osfhandle(fd)), u16.c_str(),
14401441
static_cast<dword>(u16.size()), nullptr, nullptr) != 0;

include/fmt/ostream.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ inline bool write_ostream_unicode(std::ostream& os, fmt::string_view data) {
5252
return false;
5353
#endif
5454
if (!c_file) return false;
55+
os.flush();
5556
return write_console(c_file, data);
5657
}
5758

0 commit comments

Comments
 (0)