Skip to content

Commit 2240df0

Browse files
committed
Small improvements in highlighter
1 parent 764f0c6 commit 2240df0

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
@@ -370,6 +370,8 @@ object SyntaxHighlighting {
370370
override def doReport(m: MessageContainer)(implicit ctx: Context): Unit = ()
371371
}
372372

373+
private val ignoredKwds = Seq(nme.ARROWkw, nme.EQ, nme.EQL, nme.COLONkw)
374+
373375
def highlight(in: String)(ctx0: Context): String = {
374376
import dotty.tools.dotc.ast.untpd._
375377

@@ -419,10 +421,9 @@ object SyntaxHighlighting {
419421
val sb = new mutable.StringBuilder()
420422

421423
while(s.token != EOF) {
422-
val isKwd = isKeyword(s.token)
424+
val isKwd = isKeyword(s.token) && !ignoredKwds.contains(s.name)
423425
val offsetStart = s.offset
424426

425-
426427
if(s.token == IDENTIFIER && s.name == nme.???) {
427428
highlightRange(Position(s.offset, s.offset + s.name.length), Console.RED_B)
428429
}
@@ -442,7 +443,9 @@ object SyntaxHighlighting {
442443
}
443444
sb.append(in(idx))
444445
}
445-
sb.append(NoColor)
446+
if(outputH.last != NoColor) {
447+
sb.append(NoColor)
448+
}
446449

447450
sb.mkString
448451
}

0 commit comments

Comments
 (0)