Skip to content

Conversation

@jeskew
Copy link
Member

@jeskew jeskew commented Jan 30, 2026

This PR adds keyword completions for disable-diagnostics and restore-diagnostics following a # sign. It also adds completions for the trailing error codes for these pragmas using the following rules:

  • If offering completions for #disable-diagnostics |, the completion provider returns the codes for all suppressible diagnostics that are raised after the cursor
  • If offering completions for #restore-diagnostics |, the provider returns all codes that are suppressed at the cursor
  • Completions for #restore-diagnostics do not include code from the preceding line's #disable-next-line directive (if any)

The diagnostic code completions are reactive rather than proactive, so we may need to revisit the first rule in the future if users are more often adding directives to files before adding any code that may raise those diagnostics.

Microsoft Reviewers: Open in CodeFlow

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

Test this change out locally with the following install scripts (Action run 21522770437)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 21522770437
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 21522770437"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 21522770437
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 21522770437"

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 adds IntelliSense completions for #disable-diagnostics and #restore-diagnostics pragmas in Bicep files. Previously, only #disable-next-line had completion support. The implementation provides reactive completions based on existing diagnostics in the file.

Changes:

  • Added keyword completions for #disable-diagnostics and #restore-diagnostics after typing #
  • Added diagnostic code completions for #disable-diagnostics (suggesting suppressible diagnostics that occur after the cursor)
  • Added diagnostic code completions for #restore-diagnostics (suggesting codes currently disabled at the cursor, excluding codes from preceding #disable-next-line directives)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Bicep.LangServer/Completions/BicepCompletionProvider.cs Refactored directive completion method to support all three pragma types; added completion methods for disable and restore diagnostic codes
src/Bicep.LangServer/Completions/BicepCompletionContextKind.cs Renamed enum value to be more generic (DirectiveStart) and added two new context kinds for the new directive code completions
src/Bicep.LangServer/Completions/BicepCompletionContext.cs Updated context detection logic to identify all three pragma types using switch expressions
src/Bicep.Core/Diagnostics/DisabledDiagnosticsCache.cs Added helper method to retrieve all diagnostic codes disabled at a given position
src/Bicep.LangServer.IntegrationTests/CompletionTests.cs Added comprehensive tests for the new completion functionality covering various scenarios

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

@jeskew jeskew enabled auto-merge (squash) January 30, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants