Skip to content

lsp: emit VS-internal HiddenInEditor tag for unnecessary diagnostics#3989

Open
joj wants to merge 2 commits into
microsoft:mainfrom
joj:dev/joj/lsp-unused-hidden-in-editor
Open

lsp: emit VS-internal HiddenInEditor tag for unnecessary diagnostics#3989
joj wants to merge 2 commits into
microsoft:mainfrom
joj:dev/joj/lsp-unused-hidden-in-editor

Conversation

@joj
Copy link
Copy Markdown
Member

@joj joj commented May 19, 2026

The LSP spec says clients are "allowed to render diagnostics [tagged Unnecessary] faded out instead of having an error squiggle." Visual Studio's LSP client, however, only renders the faded "unused" appearance when a diagnostic carries both DiagnosticTag.Unnecessary AND the VS-internal VSDiagnosticTags.HiddenInEditor tag; with just Unnecessary the diagnostic shows as a normal squiggle.

When the client advertises _vs_supportsVisualStudioExtensions, also emit HiddenInEditor (int32.MaxValue - 6 = 2147483641) so unused variables and similar diagnostics render faded in Visual Studio. Non-VS clients continue to receive only the standard LSP tags.

Copilot AI review requested due to automatic review settings May 19, 2026 18:21
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates LSP diagnostic tagging to make “Unnecessary” diagnostics render as faded (no squiggle) in Visual Studio by emitting a VS-specific extension tag when the client indicates VS extension support, while keeping standard LSP behavior for other clients.

Changes:

  • Added a VS-specific DiagnosticTag constant (HiddenInEditor) in the LSP protocol layer.
  • Updated diagnostic conversion to append HiddenInEditor alongside Unnecessary when talking to Visual Studio.
Show a summary per file
File Description
internal/lsp/lsproto/lsp.go Introduces a VS-specific diagnostic tag constant used to influence VS rendering.
internal/ls/lsconv/converters.go Emits the VS extension diagnostic tag (in addition to Unnecessary) when the client is Visual Studio.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread internal/lsp/lsproto/lsp.go
Comment thread internal/lsp/lsproto/lsp.go Outdated
Comment thread internal/lsp/lsproto/lsp.go Outdated
The LSP spec says clients are "allowed to render diagnostics [tagged
Unnecessary] faded out instead of having an error squiggle." Visual
Studio's LSP client, however, only renders the faded "unused" appearance
when a diagnostic carries both DiagnosticTag.Unnecessary AND the
VS-internal VSDiagnosticTags.HiddenInEditor tag; with just Unnecessary
the diagnostic shows as a normal squiggle.

When the client advertises _vs_supportsVisualStudioExtensions, also emit
HiddenInEditor (int32.MaxValue - 6 = 2147483641) so unused variables and
similar diagnostics render faded in Visual Studio. Non-VS clients
continue to receive only the standard LSP tags.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joj joj force-pushed the dev/joj/lsp-unused-hidden-in-editor branch from d8ef53b to 2510166 Compare May 19, 2026 22:35
@jakebailey jakebailey requested a review from Copilot May 20, 2026 08:19
jakebailey
jakebailey previously approved these changes May 20, 2026
Copy link
Copy Markdown
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

LGTM if it works for you

Comment thread internal/lsp/lsproto/_generate/generate.mts Outdated
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +303 to +312
tags = make([]lsproto.DiagnosticTag, 0, 3)
if diagnostic.ReportsUnnecessary() && slices.Contains(opts.tagValueSet, lsproto.DiagnosticTagUnnecessary) {
tags = append(tags, lsproto.DiagnosticTagUnnecessary)
// Visual Studio's LSP client only renders Unnecessary diagnostics as
// faded-out text when they also carry the VS-internal HiddenInEditor
// tag; otherwise they appear as a regular squiggle. Emit it so VS
// matches the LSP-spec intent of the Unnecessary tag.
if opts.visualStudio {
tags = append(tags, lsproto.DiagnosticTagVsHiddenInEditor)
}
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Copy link
Copy Markdown
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

Lgtm if it works for you

@joj joj enabled auto-merge May 20, 2026 16:51
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.

3 participants