Skip to content

Commit 7c76ded

Browse files
committed
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.
1 parent 1b0be01 commit 7c76ded

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Diff for: compiler/src/dotty/tools/dotc/interactive/Completion.scala

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

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

+14
Original file line numberDiff line numberDiff line change
@@ -2223,3 +2223,17 @@ class CompletionSuite extends BaseCompletionSuite:
22232223
|""".stripMargin,
22242224
topLines = Some(3)
22252225
)
2226+
2227+
@Test def `packageIssueIdent` =
2228+
check(
2229+
"""package one@@
2230+
|""".stripMargin,
2231+
""
2232+
)
2233+
2234+
@Test def `packageIssueSelect` =
2235+
check(
2236+
"""package one.two@@
2237+
|""".stripMargin,
2238+
""
2239+
)

0 commit comments

Comments
 (0)