Skip to content

Commit 05b01e7

Browse files
dos65tgodzik
authored andcommitted
completions: do not complete package
There is an issue with completions for package in Metals. ```scala // code package one@@ // compeltions oneCURSOR ``` It seems there is no need in completions for Package at all. [Cherry-picked 7c76ded]
1 parent ca77d84 commit 05b01e7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ object Completion:
8888
* Otherwise, provide no completion suggestion.
8989
*/
9090
def completionMode(path: List[untpd.Tree], pos: SourcePosition): Mode = path match
91+
// Ignore `package foo@@` and `package foo.bar@@`
92+
case ((_: tpd.Select) | (_: tpd.Ident)):: (_ : tpd.PackageDef) :: _ => Mode.None
9193
case GenericImportSelector(sel) =>
9294
if sel.imported.span.contains(pos.span) then Mode.ImportOrExport // import scala.@@
9395
else if sel.isGiven && sel.bound.span.contains(pos.span) then Mode.ImportOrExport

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

+14
Original file line numberDiff line numberDiff line change
@@ -2189,3 +2189,17 @@ class CompletionSuite extends BaseCompletionSuite:
21892189
|""".stripMargin,
21902190
topLines = Some(3)
21912191
)
2192+
2193+
@Test def `packageIssueIdent` =
2194+
check(
2195+
"""package one@@
2196+
|""".stripMargin,
2197+
""
2198+
)
2199+
2200+
@Test def `packageIssueSelect` =
2201+
check(
2202+
"""package one.two@@
2203+
|""".stripMargin,
2204+
""
2205+
)

0 commit comments

Comments
 (0)