diff --git a/include/fmt/color.h b/include/fmt/color.h index c933849d..816f5078 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -460,11 +460,10 @@ void vformat_to(buffer& buf, const text_style& ts, FMT_END_DETAIL_NAMESPACE inline void vprint(std::FILE* f, const text_style& ts, string_view fmt, - bool new_line, format_args args) { + format_args args) { // Legacy wide streams are not supported. auto buf = memory_buffer(); detail::vformat_to(buf, ts, fmt, args); - if (new_line) buf.push_back('\n'); if (detail::is_utf8()) { detail::print(f, string_view(buf.begin(), buf.size())); return; @@ -490,7 +489,7 @@ template ::value)> void print(std::FILE* f, const text_style& ts, const S& format_str, const Args&... args) { - vprint(f, ts, format_str, false, + vprint(f, ts, format_str, fmt::make_format_args>>(args...)); } @@ -509,8 +508,7 @@ template ::value)> void println(std::FILE* f, const text_style& ts, const S& format_str, const Args&... args) { - vprint(f, ts, format_str, true, - fmt::make_format_args>>(args...)); + print(f, ts, "{}\n", fmt::format(format_str, std::forward(args)...)); } /** diff --git a/test/color-test.cc b/test/color-test.cc index 38add10e..4616a85c 100644 --- a/test/color-test.cc +++ b/test/color-test.cc @@ -70,5 +70,5 @@ TEST(color_test, print) { EXPECT_WRITE(stdout, fmt::print(fg(fmt::rgb(255, 20, 30)), "rgb(255,20,30)"), "\x1b[38;2;255;020;030mrgb(255,20,30)\x1b[0m"); EXPECT_WRITE(stdout, fmt::println(fg(fmt::rgb(255, 20, 30)), "rgb(255,20,30)"), - "\x1b[38;2;255;020;030mrgb(255,20,30)\x1b[0m\n"); + "\x1b[38;2;255;020;030mrgb(255,20,30)\n\x1b[0m"); }