From cb686176180764a8db503fbe722ad6051da7d204 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 22 Nov 2024 19:25:34 +0100 Subject: [PATCH] bugfix: Don't send best effort flag when disabled I don't think this changes anything as we did also set build server config, but just in case. --- .../scala/scala/meta/internal/metals/Compilations.scala | 9 +++++---- .../scala/meta/internal/metals/MetalsLspService.scala | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala index 1904f266626..10f46a4badf 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala @@ -32,6 +32,7 @@ final class Compilations( onStartCompilation: () => Unit, userConfiguration: () => UserConfiguration, downstreamTargets: PreviouslyCompiledDownsteamTargets, + bestEffortEnabled: Boolean, )(implicit ec: ExecutionContext) { private val compileTimeout: Timeout = Timeout("compile", Duration(10, TimeUnit.MINUTES)) @@ -266,12 +267,12 @@ final class Compilations( scribe.debug("Compiling " + targets.mkString(", ")) val originId = "METALS-$" + UUID.randomUUID().toString val params = new b.CompileParams(targets.asJava) + val addBestEffort = + (connection.isBloop || connection.isScalaCLI) && bestEffortEnabled params.setOriginId(originId) - if ( - userConfiguration().verboseCompilation && (connection.isBloop || connection.isScalaCLI) - ) { + if (userConfiguration().verboseCompilation && addBestEffort) { params.setArguments(List("--verbose", "--best-effort").asJava) - } else if (connection.isBloop || connection.isScalaCLI) { + } else if (addBestEffort) { params.setArguments(List("--best-effort").asJava) } else params.setArguments(Nil.asJava) targets.foreach { target => diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala index 2b7761c140b..af7f9b54e59 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -222,6 +222,7 @@ abstract class MetalsLspService( onStartCompilation, () => userConfig, downstreamTargets, + clientConfig.initialConfig.enableBestEffort, ) var indexingPromise: Promise[Unit] = Promise[Unit]() def buildServerPromise: Promise[Unit]