Skip to content

Commit

Permalink
bugfix: move bsp config for detected project root
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Oct 20, 2023
1 parent 3bc135f commit fb4b251
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ final class BspConfigGenerator(
try {
val bsp = ".bsp"
workspace.resolve(bsp).createDirectories()
val buildToolBspDir = buildTool.projectRoot.resolve(bsp).toNIO
val buildToolBspDir = buildTool.projectRoot.resolve(bsp)
val workspaceBspDir = workspace.resolve(bsp).toNIO
buildToolBspDir.toFile.listFiles().foreach { file =>
val path = file.toPath()
if (!file.isDirectory() && path.filename.endsWith(".json")) {
val to =
workspaceBspDir.resolve(path.relativize(buildToolBspDir))
val to = workspaceBspDir.resolve(path.filename)
Files.move(path, to, StandardCopyOption.REPLACE_EXISTING)
}
}
Files.delete(buildToolBspDir)
buildToolBspDir.deleteRecursively()
Generated
} catch {
case NonFatal(_) =>
Failed(Right("Could not move bsp config from project root"))
case NonFatal(e) =>
val message = s"Could not move bsp config from project root: $e"
scribe.error(message)
Failed(Right(message))
}
case status => status
}
Expand Down
23 changes: 23 additions & 0 deletions tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,29 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
} yield ()
}

test("inner") {
for {
_ <- scalaCliInitialize(useBsp = false)(
s"""|/inner/project.scala
|//> using scala "$scalaVersion"
|//> using lib "com.lihaoyi::utest::0.8.1"
|/inner/MyTests.scala
|import utest._
|
|object MyTests extends TestSuite {
| val tests = Tests {
| test("foo") {
| assert(2 + 2 == 4)
| }
| }
|}
|""".stripMargin
)
_ <- server.didOpen("inner/MyTests.scala")
_ = assert(!client.workspaceDiagnostics.contains("Not found: utest"))
} yield ()
}

test("relative-semanticdb-root") {
for {
_ <- scalaCliInitialize(useBsp = false)(
Expand Down

0 comments on commit fb4b251

Please sign in to comment.