Skip to content

Commit 8d64552

Browse files
slothspotallanrenucci
authored andcommitted
Small improvements in highlighter
1 parent bf38d35 commit 8d64552

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ object SyntaxHighlighting {
374374
override def doReport(m: MessageContainer)(implicit ctx: Context): Unit = ()
375375
}
376376

377+
private val ignoredKwds = Seq(nme.ARROWkw, nme.EQ, nme.EQL, nme.COLONkw)
378+
377379
def highlight(in: String)(ctx0: Context): String = {
378380
import dotty.tools.dotc.ast.untpd._
379381

@@ -423,10 +425,9 @@ object SyntaxHighlighting {
423425
val sb = new mutable.StringBuilder()
424426

425427
while(s.token != EOF) {
426-
val isKwd = isKeyword(s.token)
428+
val isKwd = isKeyword(s.token) && !ignoredKwds.contains(s.name)
427429
val offsetStart = s.offset
428430

429-
430431
if(s.token == IDENTIFIER && s.name == nme.???) {
431432
highlightRange(Position(s.offset, s.offset + s.name.length), Console.RED_B)
432433
}
@@ -446,7 +447,9 @@ object SyntaxHighlighting {
446447
}
447448
sb.append(in(idx))
448449
}
449-
sb.append(NoColor)
450+
if(outputH.last != NoColor) {
451+
sb.append(NoColor)
452+
}
450453

451454
sb.mkString
452455
}

0 commit comments

Comments
 (0)