From 4347ad4ccf869c6d87da8f81e96698caf0e9a634 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Mon, 16 Oct 2023 12:05:08 +0200 Subject: [PATCH] bugfix: add user config promise --- .../meta/internal/metals/MetalsLspService.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 11df0204c71..aa44e3e2c7e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -137,6 +137,7 @@ class MetalsLspService( @volatile private var userConfig: UserConfiguration = initialUserConfig + private val userConfigPromise: Promise[Unit] = Promise() ThreadPools.discardRejectedRunnables("MetalsLanguageServer.sh", sh) ThreadPools.discardRejectedRunnables("MetalsLanguageServer.ec", ec) @@ -926,6 +927,7 @@ class MetalsLspService( } def setUserConfig(newConfig: UserConfiguration): UserConfiguration = { + userConfigPromise.trySuccess(()) val old = userConfig userConfig = newConfig old @@ -1548,10 +1550,13 @@ class MetalsLspService( params: SemanticTokensParams ): CompletableFuture[SemanticTokens] = { CancelTokens.future { token => - compilers.semanticTokens(params, token).map { semanticTokens => - if (semanticTokens.getData().isEmpty()) null - else semanticTokens - } + for { + _ <- userConfigPromise.future + res <- compilers.semanticTokens(params, token).map { semanticTokens => + if (semanticTokens.getData().isEmpty()) null + else semanticTokens + } + } yield res } }