Skip to content

Commit c0471e5

Browse files
committed
Fix scala#4454 '.' after Number literal is not highlighted
1 parent eb4d2c8 commit c0471e5

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ object SyntaxHighlighting {
129129
}
130130
else if (n.isUpper && keywordStart)
131131
appendWhile(n, !typeEnders.contains(_), typeDef)
132-
else if (numberStart(n))
133-
appendWhile(n, { x => x.isDigit || x == '.' || x == '\u0000'}, literal)
134-
else
132+
else if (numberStart(n)) {
133+
def isNumber(c: Char): Boolean =
134+
c.isDigit || c == '\u0000' || (c == '.' && remaining.nonEmpty && remaining.head.isDigit)
135+
appendWhile(n, isNumber , literal)
136+
} else
135137
newBuf += n; prev = n
136138
}
137139
}

compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class SyntaxHighlightingTests {
4141
@Test
4242
def literals = {
4343
test("1", "<L|1>")
44+
test("1.1", "<L|1.1>")
45+
test("1.1.toString", "<L|1.1>.toString")
4446
// test("1L", "<L|1L>")
4547
}
4648

0 commit comments

Comments
 (0)