Skip to content

Commit 0dfcc2b

Browse files
committed
merge: progress capability gate
2 parents 16ab4b0 + f7fea91 commit 0dfcc2b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/jvmMain/kotlin/io/github/dingyi222666/luaparser/lsp/LuaLanguageServer.kt‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,14 @@ class LuaLanguageServer(
304304
}
305305
}
306306

307+
@Volatile
308+
private var clientSupportsWorkDoneProgress: Boolean = false
309+
307310
override fun initialize(params: InitializeParams): CompletableFuture<InitializeResult> {
311+
clientSupportsWorkDoneProgress = params.capabilities
312+
?.window
313+
?.workDoneProgress == true
314+
println("LSP-DEVICE: client window.workDoneProgress=$clientSupportsWorkDoneProgress")
308315
println("LSP-DEVICE: initialize entered, state=$lifecycleState")
309316
return synchronized(lifecycleLock) {
310317
when (lifecycleState) {
@@ -376,6 +383,22 @@ class LuaLanguageServer(
376383
// notifications (create/report/end) so editors show indexing status.
377384
languageService.onBuildProgress = { progress ->
378385
val proxy = client
386+
// sora's client proxy throws UnsupportedOperationException on
387+
// createProgress/notifyProgress (device-verified) — when the client
388+
// didn't advertise window.workDoneProgress, log instead of spamming.
389+
val progressSink: (org.eclipse.lsp4j.jsonrpc.messages.Either<String, Int>) -> Unit = when {
390+
clientSupportsWorkDoneProgress -> { token ->
391+
proxy.notifyProgress(ProgressParams(token, Either.forRight(null as org.eclipse.lsp4j.WorkDoneProgressReport?)))
392+
}
393+
else -> { _ ->
394+
runCatching {
395+
proxy.logMessage(org.eclipse.lsp4j.MessageParams().apply {
396+
type = org.eclipse.lsp4j.MessageType.Info
397+
message = "indexing update"
398+
})
399+
}
400+
}
401+
}
379402
runCatching {
380403
when (progress.phase) {
381404
AnalysisProgress.Phase.COMPLETE -> {

0 commit comments

Comments
 (0)