From 54f1cf2b425545f89e58e23a33bc097152a89ccd Mon Sep 17 00:00:00 2001 From: zetashift Date: Wed, 15 Mar 2023 20:18:31 +0100 Subject: [PATCH] Add flush to print functions in std.Console --- .../scala/cats/effect/std/ConsoleCrossPlatform.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala b/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala index e006de773d..6ec4a1e640 100644 --- a/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala +++ b/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala @@ -239,12 +239,18 @@ private[std] abstract class ConsoleCompanionCrossPlatform { def print[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit] = { val text = a.show - F.blocking(System.out.print(text)) + F.blocking { + System.out.print(text) + System.out.flush() + } } def println[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit] = { val text = a.show - F.blocking(System.out.println(text)) + F.blocking { + System.out.println(text) + System.out.flush() + } } def error[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit] = {