Skip to content

Commit

Permalink
completions: do not complete package (#20532)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tgodzik authored Feb 28, 2025
2 parents ee62b32 + 7c76ded commit ed2f0ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/interactive/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ object Completion:
* Otherwise, provide no completion suggestion.
*/
def completionMode(path: List[untpd.Tree], pos: SourcePosition): Mode = path match
// Ignore `package foo@@` and `package foo.bar@@`
case ((_: tpd.Select) | (_: tpd.Ident)):: (_ : tpd.PackageDef) :: _ => Mode.None
case GenericImportSelector(sel) =>
if sel.imported.span.contains(pos.span) then Mode.ImportOrExport // import scala.@@
else if sel.isGiven && sel.bound.span.contains(pos.span) then Mode.ImportOrExport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2223,3 +2223,17 @@ class CompletionSuite extends BaseCompletionSuite:
|""".stripMargin,
topLines = Some(3)
)

@Test def `packageIssueIdent` =
check(
"""package one@@
|""".stripMargin,
""
)

@Test def `packageIssueSelect` =
check(
"""package one.two@@
|""".stripMargin,
""
)

0 comments on commit ed2f0ad

Please sign in to comment.