Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: add user config promise #5751

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -928,6 +929,7 @@ class MetalsLspService(
def setUserConfig(newConfig: UserConfiguration): UserConfiguration = {
val old = userConfig
userConfig = newConfig
userConfigPromise.trySuccess(())
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, we could have a similar issue with parent code lenses superMethodLensesEnabled, no? Though I think we might send refresh in that case 🤔 We might also send refresh for semantic tokens when they change.

Maybe we should wait for the build server promise, which should most likely be after requesting semantic tokens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code lenses already wait for the buildServerPromise so that's fine.

res <- compilers.semanticTokens(params, token).map { semanticTokens =>
if (semanticTokens.getData().isEmpty()) null
else semanticTokens
}
} yield res
}
}

Expand Down