Skip to content

Commit 54b3845

Browse files
committed
.
1 parent 74cc11d commit 54b3845

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ trait MessageRendering {
205205
def explanation(m: Message)(using Context): String = {
206206
val sb = new StringBuilder(
207207
s"""|
208-
|${fansi.Color.Blue("Explanation").render}
209-
|${fansi.Color.Blue("===========").render}""".stripMargin
208+
|${if ctx.useColors then fansi.Color.Blue("Explanation").render else "Explanation"}
209+
|${if ctx.useColors then fansi.Color.Blue("===========").render else "==========="}""".stripMargin
210210
)
211211
sb.append(EOL).append(m.explanation)
212212
if (!m.explanation.endsWith(EOL)) sb.append(EOL)
@@ -305,10 +305,12 @@ trait MessageRendering {
305305
}
306306

307307
private def hl(str: String)(using Context, Level): String =
308-
summon[Level].value match
309-
case interfaces.Diagnostic.ERROR => fansi.Color.Red(str).render
310-
case interfaces.Diagnostic.WARNING => fansi.Color.Yellow(str).render
311-
case interfaces.Diagnostic.INFO => fansi.Color.Blue(str).render
308+
if ctx.useColors then
309+
summon[Level].value match
310+
case interfaces.Diagnostic.ERROR => fansi.Color.Red(str).render
311+
case interfaces.Diagnostic.WARNING => fansi.Color.Yellow(str).render
312+
case interfaces.Diagnostic.INFO => fansi.Color.Blue(str).render
313+
else str
312314

313315
private def diagnosticLevel(dia: Diagnostic): String =
314316
dia match {

0 commit comments

Comments
 (0)