Open
Description
Follow up on #27614
Search terms
- code action / codeaction
- quick fix / quickfix
getCodeFixes
getSupportedCodeFixes
Problem
The getCodeFixes
API currently takes a range plus a diagnostic code. Currently, the range we pass to it has to match the range of the diagnostic we are trying to fix. This API is difficult for editors to implement for a few reasons:
- We need to make multiple requests if we want to display quick fixes for multiple (potentially overlapping) diagnostics
- The editor has to ensure that the diagnostics as fully synchronized with the current text buffer state before making the request. It's easy for the editor's diagnostics to get temporarily out of sync with those on the server
- The editor has to keep around a list of diagnostics to make these requests
Proposal
We should consider a new quick fix API that addresses these problems and also is better aligned with the language server protocol. My proposal is that instead of having to think about diagnostics, editors pass the TS Server a range and are returned the valid quick fixes in that range.
Here's what the VS Code api for this looks like:
And here's the LSP: