Skip to content

Commit 6153905

Browse files
authored
Merge pull request #5490 from dotty-staging/fix/5482
Fix #5482: Empty buffer when not parsing comments
2 parents 2c45bb0 + 5fee131 commit 6153905

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,11 @@ object Scanners {
631631
nextChar()
632632
if (ch == '/') { skipLine(); finishComment() }
633633
else if (ch == '*') { nextChar(); skipComment(); finishComment() }
634-
else false
634+
else {
635+
// This was not a comment, remove the `/` from the buffer
636+
commentBuf.clear()
637+
false
638+
}
635639
}
636640

637641
// Lookahead ---------------------------------------------------------------

language-server/test/dotty/tools/languageserver/HoverTest.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ class HoverTest {
164164
|
165165
|**Version**
166166
| - 1.0""".stripMargin))
167+
}
167168

169+
@Test def i5482: Unit = {
170+
code"""object Test {
171+
| def bar: Int = 2 / 1
172+
| /** hello */
173+
| def ${m1}baz${m2}: Int = ???
174+
|}""".withSource
175+
.hover(m1 to m2, hoverContent("Int", "hello"))
168176
}
169177
}

0 commit comments

Comments
 (0)