diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index 08a34a2e9fbc..410a6a0c8266 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -129,9 +129,11 @@ object SyntaxHighlighting { } else if (n.isUpper && keywordStart) appendWhile(n, !typeEnders.contains(_), typeDef) - else if (numberStart(n)) - appendWhile(n, { x => x.isDigit || x == '.' || x == '\u0000'}, literal) - else + else if (numberStart(n)) { + def isNumber(c: Char): Boolean = + c.isDigit || c == '\u0000' || (c == '.' && remaining.nonEmpty && remaining.head.isDigit) + appendWhile(n, isNumber, literal) + } else newBuf += n; prev = n } } diff --git a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala index 7166d3cb0db1..cceaa48cf5b3 100644 --- a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala +++ b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala @@ -41,6 +41,8 @@ class SyntaxHighlightingTests { @Test def literals = { test("1", "") + test("1.1", "") + test("1.1.toString", ".toString") // test("1L", "") }