Microsoft/vscode
在 GitHub 查看Code action request from problems view includes additional diagnostics
Open
#161,331 创建于 2022年9月20日
bugeditor-code-actionserror-listhelp wanted
仓库指标
- Star
- (74,848 star)
- PR 合并指标
- (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)
描述
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:
- Have a project that has multiple diagnostics for the same range and where each diagnostic has a suggested fix.
- 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}}
