Skip to content

fix(diagnostic): ensure diagnostic request after didOpen#5540

Merged
fannheyward merged 1 commit intomasterfrom
fix/request-order
Feb 10, 2026
Merged

fix(diagnostic): ensure diagnostic request after didOpen#5540
fannheyward merged 1 commit intomasterfrom
fix/request-order

Conversation

@fannheyward
Copy link
Copy Markdown
Member

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.91%. Comparing base (14f80a9) to head (3e7b300).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/language-client/diagnostic.ts 53.84% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5540      +/-   ##
==========================================
- Coverage   97.97%   97.91%   -0.07%     
==========================================
  Files         280      280              
  Lines       27887    27899      +12     
  Branches     5772     5777       +5     
==========================================
- Hits        27321    27316       -5     
- Misses        107      113       +6     
- Partials      459      470      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the diagnostic pull logic to avoid suppressing the “pull on open” behavior when the client only “knows” about a document via an older version or certain in-flight request states, helping ensure a diagnostic request is issued after didOpen.

Changes:

  • Add tracksSameVersion to DocumentPullStateTracker to check whether a tracked pull state matches the current document version.
  • Add knowsSameVersion to DiagnosticRequestor to factor in open request state + version when deciding whether diagnostics are already “known”.
  • Switch the didOpen diagnostic trigger guard from knows(...) to knowsSameVersion(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +205 to +210
public tracksSameVersion(kind: PullState, document: TextDocument): boolean {
const key = document.uri.toString()
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates
const state = states.get(key)
return state !== undefined && state.pulledVersion === document.version
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

tracksSameVersion/knowsSameVersion build the map key via document.uri.toString(), while the rest of this file consistently uses DocumentOrUri.asKey(...) for openRequests and pull state maps. Using the helper here would avoid subtle key mismatches if URI normalization ever changes and keeps keying logic in one place.

Copilot uses AI. Check for mistakes.
Comment on lines +268 to +282
public knowsSameVersion(kind: PullState, document: TextDocument): boolean {
const requestState = this.openRequests.get(document.uri.toString())
if (requestState === undefined) {
return this.documentStates.tracksSameVersion(kind, document)
}
// A reschedule request is independent of a version so it will trigger
// on the latest version no matter what.
if (requestState.state === RequestStateKind.reschedule) {
return true
}
if (requestState.state === RequestStateKind.outDated) {
return false
}
return requestState.version === document.version
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

New version-aware behavior (tracksSameVersion + knowsSameVersion, and the didOpen gating change) isn’t covered by tests. Since there are already tests for DocumentPullStateTracker and DiagnosticFeature under src/__tests__/client/diagnostics.test.ts, it would be good to add cases for: tracked state with same/different pulledVersion, an active request with same/different version, and outDated/reschedule request states, to ensure didOpen triggers (or skips) pulls as intended.

Copilot uses AI. Check for mistakes.
@fannheyward fannheyward merged commit f585a9a into master Feb 10, 2026
8 of 10 checks passed
@fannheyward fannheyward deleted the fix/request-order branch February 10, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants