Skip to content

Commit

Permalink
bugfix: Future filter error during connecting to build server
Browse files Browse the repository at this point in the history
If we get to the state that selected build tool is no longer available, Metals would crash.
This happend in `MetalsLspService.buildTool` if `BuildToolSelector.checkForChosenBuildTool` returned Future(None)
  • Loading branch information
jkciesluk committed Oct 19, 2023
1 parent 505e58c commit 2dc3125
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ final class BuildToolSelector(
buildTools: List[BuildTool]
): Future[Option[BuildTool]] =
tables.buildTool.selectedBuildTool match {
case Some(chosen) =>
case Some(chosen) if buildTools.exists(_.executableName == chosen) =>
Future(buildTools.find(_.executableName == chosen))
case None =>
case _ =>
buildTools match {
case buildTool :: Nil =>
tables.buildTool.chooseBuildTool(buildTool.executableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1970,11 +1970,10 @@ class MetalsLspService(
case Nil => Future(None)
case buildTools =>
for {
Some(buildTool) <- buildToolSelector.checkForChosenBuildTool(
buildTool <- buildToolSelector.checkForChosenBuildTool(
buildTools
)
if isCompatibleVersion(buildTool)
} yield Some(buildTool)
} yield buildTool.filter(isCompatibleVersion)
}
}

Expand Down

0 comments on commit 2dc3125

Please sign in to comment.