Skip to content

Commit

Permalink
Merge pull request #2817 from tgodzik/position-imports-comment
Browse files Browse the repository at this point in the history
Fix issues when importing in an empty package
  • Loading branch information
tgodzik authored May 24, 2021
2 parents 10c680a + b853078 commit 8bf50c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ object AutoImports {
pkg.stats.takeWhile(_.isInstanceOf[Import]).lastOption
val (lineNumber, padTop) = lastImportStatement match {
case Some(stm) => (stm.endPos.line + 1, false)
case None if pkg.pid.symbol.isEmptyPackage =>
(0, false)
case None =>
val pos = pkg.pid.endPos
val line =
Expand Down
21 changes: 21 additions & 0 deletions tests/cross/src/test/scala/tests/pc/AutoImportsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ class AutoImportsSuite extends BaseAutoImportsSuite {
|""".stripMargin
)

checkEdit(
"basic-edit-comment",
"""|/**
| * @param code
| * @return
|*/
|object A {
| <<Future>>.successful(2)
|}
|""".stripMargin,
"""|import scala.concurrent.Future
|/**
| * @param code
| * @return
|*/
|object A {
| Future.successful(2)
|}
|""".stripMargin
)

checkEdit(
"symbol-no-prefix",
"""|package a
Expand Down

0 comments on commit 8bf50c7

Please sign in to comment.