diff --git a/metals/src/main/scala/scala/meta/internal/metals/ClientExperimentalCapabilities.scala b/metals/src/main/scala/scala/meta/internal/metals/ClientExperimentalCapabilities.scala index f3b72c6b333..6d77380e255 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ClientExperimentalCapabilities.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ClientExperimentalCapabilities.scala @@ -11,6 +11,7 @@ final case class ClientExperimentalCapabilities( didFocusProvider: java.lang.Boolean = false, slowTaskProvider: java.lang.Boolean = false, executeClientCommandProvider: java.lang.Boolean = false, + openFilesOnRenameProvider: java.lang.Boolean = false, doctorProvider: String = "html", statusBarProvider: String = "off" ) { diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala index 338db88bc4b..9d9f50b7408 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala @@ -393,7 +393,8 @@ class MetalsLanguageServer( languageClient, buffers, compilations, - config + config, + clientExperimentalCapabilities ) semanticDBIndexer = new SemanticdbIndexer( referencesProvider, diff --git a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala index a50fbdc0a95..fb40a791dd1 100644 --- a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala @@ -35,6 +35,7 @@ import scala.meta.internal.async.ConcurrentQueue import scala.meta.internal.semanticdb.Synthetic import scala.meta.internal.semanticdb.SelectTree import scala.meta.internal.metals.MetalsServerConfig +import scala.meta.internal.metals.ClientExperimentalCapabilities final class RenameProvider( referenceProvider: ReferenceProvider, @@ -46,7 +47,8 @@ final class RenameProvider( client: MetalsLanguageClient, buffers: Buffers, compilations: Compilations, - metalsConfig: MetalsServerConfig + metalsConfig: MetalsServerConfig, + clientExperimentalCapabilities: ClientExperimentalCapabilities ) { private var awaitingSave = new ConcurrentLinkedQueue[() => Unit] @@ -144,12 +146,13 @@ final class RenameProvider( Seq(uri.toAbsolutePath -> textEdits.toList) } val fileChanges = allChanges.flatten.toMap + val openFilesOnRenameProvider = + metalsConfig.openFilesOnRenames || clientExperimentalCapabilities.openFilesOnRenameProvider val shouldRenameInBackground = - !metalsConfig.openFilesOnRenames || - fileChanges.keySet.size >= metalsConfig.renameFileThreshold + !openFilesOnRenameProvider || fileChanges.keySet.size >= metalsConfig.renameFileThreshold val (openedEdits, closedEdits) = if (shouldRenameInBackground) { - if (metalsConfig.openFilesOnRenames) { + if (openFilesOnRenameProvider) { client.showMessage(fileThreshold(fileChanges.keySet.size)) } fileChanges.partition {