Microsoft/vscode

Code action request from problems view includes additional diagnostics

Open

#161,331 opened on Sep 20, 2022

View on GitHub
 (2 comments) (16 reactions) (1 assignee)TypeScript (10,221 forks)batch import
bugeditor-code-actionserror-listhelp wanted

Repository metrics

Stars
 (74,848 stars)
PR merge metrics
 (Avg merge 11h 43m) (1,000 merged PRs in 30d)

Description

Does this issue occur when all extensions are disabled?: No

  • VS Code Version: 1.71.1
  • OS Version: macOS Monterey version 12.6

Steps to Reproduce:

  1. Have a project that has multiple diagnostics for the same range and where each diagnostic has a suggested fix.
  2. Open the problems view and hover over one of the diagnostics to get the code actions for that diagnostic.

I would expect to see the code action just for that diagnostic, not all diagnostics in the same range. The LSP textDocument/codeAction request includes all of the diagnostics in that range as the context for the codeAction request, not just the selected one in the problems view.

For example, the two diagnostics below have the same line. Getting the quick fixes for one diagnostic, will send a request with both diagnostics included in the context:

Params: {"textDocument":{"uri":"file:///Users/suzmue/govulncheck-study/module5/go.mod"},"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":32}},"context":{"diagnostics":[{"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":32}},"message":"github.com/tidwall/gjson can be upgraded","severity":3,"source":"upgrade available"},{"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":32}},"message":"Vulnerability found:\nA maliciously crafted path can cause Get and other query functions\nto consume excessive amounts of CPU and time.","code":"GO-2021-0265","codeDescription":{"href":"https://pkg.go.dev/vuln/GO-2021-0265"},"severity":2,"source":"vulncheck"}],"triggerKind":2}}

Screen Shot 2022-09-20 at 1 44 50 PM

Contributor guide