Skip to content

Commit d50b952

Browse files
committed
Detect whether the client supports server-initiated work-done progress
1 parent 2a2b4fb commit d50b952

6 files changed

Lines changed: 54 additions & 0 deletions

File tree

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- **Progress notifications.** The server no longer sends `window/workDoneProgress/create` requests to clients that do not advertise support for it. Previously this could block clients indefinitely while they waited for a response that never came.
1213
- **Change visibility.** The code action no longer appears when the cursor is inside a method body. It now only triggers on the method signature (modifiers, name, parameters, return type).
1314
- **Update docblock.** The code action no longer appears when the cursor is inside a function or method body. It now only triggers on the signature or the preceding docblock.
1415
- **Update docblock.** No longer suggests adding redundant `@param` tags when the docblock has no `@param` tags and all parameters already have sufficient native type hints. This matches the generate-docblock behaviour, which intentionally omits `@param` for fully-typed non-templated parameters.

docs/todo.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ within the same impact tier.
1919

2020
# Scheduled Sprints
2121

22+
## Sprint 3 — Bug fixes
23+
24+
| # | Item | Impact | Effort |
25+
| --- | ------------------------------------------------- | ------ | ------ |
26+
| B13 | [Stop showing dummy symbols in hover](todo/bugs.md#b13--hover-shows-dummy-symbols) | Medium | Low |
27+
2228
## Sprint 4 — Refactoring toolkit
2329

2430
| # | Item | Impact | Effort |

docs/todo/bugs.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,19 @@ In practice this is unlikely because pruning only ever removes entries
5555
**Fix:** Replace the length comparison with a content comparison, or
5656
unconditionally write the pruned set back into the cache (the extra
5757
write is negligible).
58+
59+
---
60+
61+
## B13 — Hover shows dummy symbols
62+
63+
| Impact | Effort |
64+
| ------ | ------ |
65+
| Medium | Low |
66+
67+
When hovering over certain constructs the hover popup displays
68+
internal dummy/placeholder symbols instead of filtering them out.
69+
These symbols are not meaningful to the user and clutter the hover
70+
output.
71+
72+
**Fix:** Filter out dummy symbols before building the hover response
73+
so only real, user-relevant information is shown.

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,13 @@ pub struct Backend {
438438
/// the rename response includes a `RenameFile` operation alongside the
439439
/// text edits so the file is renamed to match the new class name.
440440
pub(crate) supports_file_rename: Arc<std::sync::atomic::AtomicBool>,
441+
/// Whether the client supports server-initiated work-done progress.
442+
///
443+
/// Set during `initialize` based on the client's
444+
/// `window.workDoneProgress` capability. When `false`, the server
445+
/// must not send `window/workDoneProgress/create` requests because
446+
/// the client will not handle them, blocking the server indefinitely.
447+
pub(crate) supports_work_done_progress: Arc<std::sync::atomic::AtomicBool>,
441448
/// Shared flag set to `true` when the LSP `shutdown` request is
442449
/// received. Background workers (diagnostic, PHPStan) check this
443450
/// flag on each iteration and exit their loops. The PHPStan
@@ -504,6 +511,7 @@ impl Backend {
504511
diag_last_full: Arc::new(Mutex::new(HashMap::new())),
505512
supports_pull_diagnostics: Arc::new(std::sync::atomic::AtomicBool::new(false)),
506513
supports_file_rename: Arc::new(std::sync::atomic::AtomicBool::new(false)),
514+
supports_work_done_progress: Arc::new(std::sync::atomic::AtomicBool::new(false)),
507515
shutdown_flag: Arc::new(std::sync::atomic::AtomicBool::new(false)),
508516
config: Mutex::new(config::Config::default()),
509517
}
@@ -702,6 +710,7 @@ impl Backend {
702710
diag_last_full: Arc::clone(&self.diag_last_full),
703711
supports_pull_diagnostics: Arc::clone(&self.supports_pull_diagnostics),
704712
supports_file_rename: Arc::clone(&self.supports_file_rename),
713+
supports_work_done_progress: Arc::clone(&self.supports_work_done_progress),
705714
shutdown_flag: Arc::clone(&self.shutdown_flag),
706715
config: Mutex::new(self.config.lock().clone()),
707716
}

src/server.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ impl LanguageServer for Backend {
8080
self.supports_file_rename
8181
.store(client_supports_file_rename, Ordering::Release);
8282

83+
// Detect whether the client supports server-initiated work-done
84+
// progress (window/workDoneProgress/create). Per the LSP spec,
85+
// we must not send that request unless the client opts in.
86+
let client_supports_work_done_progress = params
87+
.capabilities
88+
.window
89+
.as_ref()
90+
.and_then(|w| w.work_done_progress)
91+
.unwrap_or(false);
92+
self.supports_work_done_progress
93+
.store(client_supports_work_done_progress, Ordering::Release);
94+
8395
Ok(InitializeResult {
8496
offset_encoding: None,
8597
capabilities: ServerCapabilities {

src/util.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,16 @@ impl Backend {
840840
pub(crate) async fn progress_create(&self, token_name: &str) -> Option<NumberOrString> {
841841
use tower_lsp::lsp_types::request::WorkDoneProgressCreate;
842842

843+
// Per the LSP spec, servers must only use
844+
// window/workDoneProgress/create when the client signals
845+
// support via the window.workDoneProgress capability.
846+
if !self
847+
.supports_work_done_progress
848+
.load(std::sync::atomic::Ordering::Relaxed)
849+
{
850+
return None;
851+
}
852+
843853
let client = self.client.as_ref()?;
844854
let token = NumberOrString::String(token_name.to_string());
845855
let params = WorkDoneProgressCreateParams {

0 commit comments

Comments
 (0)