Skip to content

Commit ac6315b

Browse files
committed
Various highlight fixes
1 parent 2e0ea4c commit ac6315b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
346346
case id: Trees.SearchFailureIdent[_] =>
347347
tree.typeOpt match {
348348
case reason: Implicits.SearchFailureType =>
349-
toText(id.name) ~ "implicitly" ~ toText(reason.expectedType) ~ "]"
349+
toText(id.name) ~ "implicitly[" ~ toText(reason.expectedType) ~ "]"
350350
case _ =>
351351
toText(id.name)
352352
}
@@ -411,7 +411,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
411411
if (sel.isEmpty) blockText(cases)
412412
else changePrec(GlobalPrec) { toText(sel) ~ keywordStr(" match ") ~ blockText(cases) }
413413
case CaseDef(pat, guard, body) =>
414-
keywordStr("case ") ~ inPattern(toText(pat)) ~ optText(guard)(" if " ~ _) ~ " => " ~ caseBlockText(body)
414+
keywordStr("case ") ~ inPattern(toText(pat)) ~ optText(guard)(keywordStr(" if ") ~ _) ~ " => " ~ caseBlockText(body)
415415
case Return(expr, from) =>
416416
changePrec(GlobalPrec) { keywordStr("return") ~ optText(expr)(" " ~ _) }
417417
case Try(expr, cases, finalizer) =>

compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object SyntaxHighlighting {
1717
val KeywordColor = Console.YELLOW
1818
val ValDefColor = Console.CYAN
1919
val LiteralColor = Console.RED
20-
val StringColor = Console.GREEN
20+
val StringColor = Console.GREEN
2121
val TypeColor = Console.MAGENTA
2222
val AnnotationColor = Console.MAGENTA
2323

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@ object DiffUtil {
77

88
val EOF = new String("EOF") // Unique string up to reference
99

10+
val ansiColorToken = '\u001b'
11+
1012
@tailrec private def splitTokens(str: String, acc: List[String] = Nil): List[String] = {
1113
if (str == "") {
1214
acc.reverse
1315
} else {
1416
val head = str.charAt(0)
1517
val (token, rest) =
16-
if (head == '\u001b') { // ansi color token
18+
if (head == ansiColorToken) { // ansi color token
1719
val splitIndex = str.indexOf('m') + 1
1820
(str.substring(0, splitIndex), str.substring(splitIndex))
1921
} else if (Character.isAlphabetic(head) || Character.isDigit(head)) {
20-
str.span(c => Character.isAlphabetic(c) || Character.isDigit(c) && c != '\u001b')
22+
str.span(c => Character.isAlphabetic(c) || Character.isDigit(c) && c != ansiColorToken)
2123
} else if (Character.isMirrored(head) || Character.isWhitespace(head)) {
2224
str.splitAt(1)
2325
} else {
2426
str.span { c =>
2527
!Character.isAlphabetic(c) && !Character.isDigit(c) &&
26-
!Character.isMirrored(c) && !Character.isWhitespace(c) && c != '\u001b'
28+
!Character.isMirrored(c) && !Character.isWhitespace(c) && c != ansiColorToken
2729
}
2830
}
2931
splitTokens(rest, token :: acc)

0 commit comments

Comments
 (0)