Skip to content

Commit

Permalink
bugfix: add user config promise
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Oct 17, 2023
1 parent b1038e6 commit a2d4ebc
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -929,6 +930,7 @@ class MetalsLspService(
def setUserConfig(newConfig: UserConfiguration): UserConfiguration = {
val old = userConfig
userConfig = newConfig
userConfigPromise.trySuccess(())
old
}

Expand Down Expand Up @@ -1549,10 +1551,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
}
}

Expand Down

0 comments on commit a2d4ebc

Please sign in to comment.