Skip to content

Commit 9396006

Browse files
Merge pull request #1416 from dotty-staging/fix/Xprint-colors
-Xprint-diff-del: more meaningful colors
2 parents 1b0315c + 8f3b620 commit 9396006

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/dotty/tools/dotc/util/DiffUtil.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ object DiffUtil {
88
private final val ANSI_DEFAULT = "\u001B[0m"
99
private final val ANSI_RED = "\u001B[31m"
1010
private final val ANSI_GREEN = "\u001B[32m"
11-
private final val ANSI_YELLOW = "\u001B[33m"
12-
private final val ANSI_MAGENTA = "\u001B[35m"
11+
12+
private final val DELETION_COLOR = ANSI_RED
13+
private final val ADDITION_COLOR = ANSI_GREEN
1314

1415
def mkColoredCodeDiff(code: String, lastCode: String, printDiffDel: Boolean): String = {
1516
import scala.collection.JavaConversions._
@@ -42,19 +43,19 @@ object DiffUtil {
4243

4344
delta.getType.toString match { // Issue #1355 forces us to use the toString
4445
case "INSERT" =>
45-
lines(pos) = ANSI_GREEN + lines(pos)
46+
lines(pos) = ADDITION_COLOR + lines(pos)
4647
lines(endPos) = lines(endPos) + ANSI_DEFAULT
4748

4849
case "CHANGE" =>
4950
val old = if (!printDiffDel) "" else
50-
ANSI_MAGENTA + delta.getOriginal.getLines.mkString + ANSI_DEFAULT
51-
lines(pos) = old + ANSI_YELLOW + lines(pos)
51+
DELETION_COLOR + delta.getOriginal.getLines.mkString + ANSI_DEFAULT
52+
lines(pos) = old + ADDITION_COLOR + lines(pos)
5253
lines(endPos) = lines(endPos) + ANSI_DEFAULT
5354

5455
case "DELETE" if printDiffDel =>
5556
val deleted = delta.getOriginal.getLines.mkString
5657
if (!deleted.forall(Character.isWhitespace)) {
57-
lines(pos) = ANSI_RED + deleted + ANSI_DEFAULT + lines(pos)
58+
lines(pos) = DELETION_COLOR + deleted + ANSI_DEFAULT + lines(pos)
5859
}
5960

6061
case _ =>

0 commit comments

Comments
 (0)