Microsoft/vscode

Code action request from problems view includes additional diagnostics

Open

#161.331 aperta il 20 set 2022

Vedi su GitHub
 (2 commenti) (16 reazioni) (1 assegnatario)TypeScript (10.221 fork)batch import
bugeditor-code-actionserror-listhelp wanted

Metriche repository

Star
 (74.848 star)
Metriche merge PR
 (Merge medio 11h 43m) (1000 PR mergiate in 30 g)

Descrizione

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

Guida contributor