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 16, 2023
1 parent 63a65d2 commit 4347ad4
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 @@ -926,6 +927,7 @@ class MetalsLspService(
}

def setUserConfig(newConfig: UserConfiguration): UserConfiguration = {
userConfigPromise.trySuccess(())
val old = userConfig
userConfig = newConfig
old
Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit 4347ad4

Please sign in to comment.