Skip to content

Commit da6d314

Browse files
authored
Merge pull request #271 from scala/backport-lts-3.3-20532
Backport "completions: do not complete package" to 3.3 LTS
2 parents 0fcd897 + 05b01e7 commit da6d314

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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)