Skip to content

Commit 27c92da

Browse files
slothspotallanrenucci
authored andcommitted
Small improvements in highlighter
1 parent be2e6b4 commit 27c92da

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

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

@@ -418,10 +420,9 @@ object SyntaxHighlighting {
418420
val sb = new mutable.StringBuilder()
419421

420422
while(s.token != EOF) {
421-
val isKwd = isKeyword(s.token)
423+
val isKwd = isKeyword(s.token) && !ignoredKwds.contains(s.name)
422424
val offsetStart = s.offset
423425

424-
425426
if(s.token == IDENTIFIER && s.name == nme.???) {
426427
highlightRange(Position(s.offset, s.offset + s.name.length), Console.RED_B)
427428
}
@@ -441,7 +442,9 @@ object SyntaxHighlighting {
441442
}
442443
sb.append(in(idx))
443444
}
444-
sb.append(NoColor)
445+
if(outputH.last != NoColor) {
446+
sb.append(NoColor)
447+
}
445448

446449
sb.mkString
447450
}

0 commit comments

Comments
 (0)