Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: deduplicate auto connect requests for scala-cli #5645

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ class ScalaCliBuildTool(
Future.successful(Generated)
}

def createBspConfigIfNone(
workspace: AbsolutePath,
systemProcess: List[String] => Future[BspConfigGenerationStatus],
statusBar: StatusBar,
): Future[BspConfigGenerationStatus] = {
if (ScalaCliBuildTool.pathsToScalaCliBsp(workspace).exists(_.isFile))
Future.successful(Generated)
else generateBspConfig(workspace, systemProcess, statusBar)
}

override def createBspFileArgs(
workspace: AbsolutePath
): Option[List[String]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1991,16 +1991,19 @@ class MetalsLspService(
Future.successful(BuildChange.None)
case (Some(_), buildTool: ScalaCliBuildTool)
if chosenBuildServer.isEmpty =>
for {
_ <- buildTool.createBspConfigIfNone(
folder,
args =>
bspConfigGenerator.runUnconditionally(buildTool, args),
statusBar,
)
_ = tables.buildServers.chooseServer(ScalaCliBuildTool.name)
buildChange <- quickConnectToBuildServer()
} yield buildChange
tables.buildServers.chooseServer(ScalaCliBuildTool.name)
val scalaCliBspConfigExists =
ScalaCliBuildTool.pathsToScalaCliBsp(folder).exists(_.isFile)
if (scalaCliBspConfigExists) Future.successful(BuildChange.None)
else
buildTool
.generateBspConfig(
folder,
args =>
bspConfigGenerator.runUnconditionally(buildTool, args),
statusBar,
)
.flatMap(_ => quickConnectToBuildServer())
case (Some(digest), _) if isBloopOrEmpty =>
slowConnectToBloopServer(forceImport, buildTool, digest)
case (Some(digest), _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
.inverseSources(workspace.resolve(fileName))
.isDefined
for {
_ <- scalaCliInitialize(useBsp = false)(
_ <- initialize(
s"""/src/Main.scala
|object Main:
| def foo = 3
Expand Down