Skip to content

Refresh diagnostics for open PowerShell docs#5402

Open
mdaneri wants to merge 2 commits intoPowerShell:mainfrom
mdaneri:fix/5381-refresh-open-doc-diagnostics
Open

Refresh diagnostics for open PowerShell docs#5402
mdaneri wants to merge 2 commits intoPowerShell:mainfrom
mdaneri:fix/5381-refresh-open-doc-diagnostics

Conversation

@mdaneri
Copy link

@mdaneri mdaneri commented Feb 17, 2026

PR Summary

  • refresh analysis for already-open PowerShell documents once the language client reaches Running
  • replay textDocument/didClose + textDocument/didOpen for open file and untitled PowerShell docs
  • avoid requiring a manual edit to clear false custom-attribute type diagnostics on initial open

Related Issue

Fixes #5381

Testing

  • verified extension builds with npm run compile
  • validated issue repro: initial false diagnostics clear without typing after session startup

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

Force re-analysis of open PowerShell documents after the language server starts. Adds DidOpenTextDocument and DidCloseTextDocument notification types and a refreshOpenPowerShellDocumentDiagnostics() helper that filters open documents (powershell, file/untitled), logs the action, and sends didClose followed by didOpen (including languageId, version and text) to the language client. The method is invoked after the session reports it has started; it no-ops if the client isn't running or there are no matching open documents.
Copilot AI review requested due to automatic review settings February 17, 2026 10:33
Copy link

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

This PR addresses false diagnostics that appear when PowerShell documents are initially opened before the language server is fully initialized. The solution refreshes analysis for all open PowerShell documents once the language client reaches the Running state.

Changes:

  • Added custom notification types for textDocument/didOpen and textDocument/didClose
  • Implemented refreshOpenPowerShellDocumentDiagnostics() method to replay close/open events for already-open PowerShell documents
  • Called the refresh method after the language client is confirmed running during session startup

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

Prefix this.languageClient.sendNotification calls with the void operator to explicitly discard the returned Promise and avoid floating-promise/unused-Promise warnings. Applied to notifications sent for DidCloseTextDocumentNotificationType and DidOpenTextDocumentNotificationType when iterating open PowerShell documents.
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.

PowerShell Custom Attribute Types Unresolved on Initial File Open

1 participant

Comments