From 78d8150e804876f86a53b5adca96113b1254938f Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 15 Dec 2022 19:28:22 +0100 Subject: [PATCH] bugfix: Work around fansi escaping issues Previously, some error messages might have been not able to be printed due to a bug in fansi https://github.com/com-lihaoyi/fansi/issues/46 Now, we added a workaround that should help out here. Fixes https://github.com/scalameta/mdoc/issues/730 --- .../mdoc/internal/io/ConsoleReporter.scala | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mdoc/src/main/scala/mdoc/internal/io/ConsoleReporter.scala b/mdoc/src/main/scala/mdoc/internal/io/ConsoleReporter.scala index 6daffddcb..3b28331ad 100644 --- a/mdoc/src/main/scala/mdoc/internal/io/ConsoleReporter.scala +++ b/mdoc/src/main/scala/mdoc/internal/io/ConsoleReporter.scala @@ -1,11 +1,14 @@ package mdoc.internal.io +import coursierapi.Logger +import fansi.ErrorMode +import fansi.Str +import mdoc.Reporter +import mdoc.internal.pos.PositionSyntax._ + import java.io.PrintStream import java.util.concurrent.atomic.AtomicBoolean import scala.meta.Position -import mdoc.Reporter -import mdoc.internal.pos.PositionSyntax._ -import coursierapi.Logger class ConsoleReporter( ps: PrintStream, @@ -49,24 +52,24 @@ class ConsoleReporter( } def error(msg: String): Unit = { myErrors += 1 - ps.println(myError ++ s": $msg") + ps.println(myError ++ Str(s": $msg", ErrorMode.Strip)) } def warning(pos: Position, msg: String): Unit = { warning(formatMessage(pos.toUnslicedPosition, "warning", msg)) } def warning(msg: String): Unit = { myWarnings += 1 - ps.println(myWarning ++ s": $msg") + ps.println(myWarning ++ Str(s": $msg", ErrorMode.Strip)) } def info(pos: Position, msg: String): Unit = { info(formatMessage(pos.toUnslicedPosition, "info", msg)) } def info(msg: String): Unit = { - ps.println(myInfo ++ s": $msg") + ps.println(myInfo ++ Str(s": $msg", ErrorMode.Strip)) } def debug(msg: => String): Unit = { if (isDebugEnabled.get()) { - ps.println(myDebug ++ s": $msg") + ps.println(myDebug ++ Str(s": $msg", ErrorMode.Strip)) } }