With the help of the VS Code Extension API, I can get all current diagnostics in the open editors like this:
const allDiagnostics = vscode.languages.getDiagnostics();
I have written a command that deletes all mentions that generate these diagnostics: when you hover on the diagnostic, and click "Quick Fix...", the command appears, and after clicking it, all those mentions that produce the diagnostics are deleted from the editor:
However, I have not been able to find a way to get the selected diagnostic. For example, in the picture above, I would like the command to delete only Calibrate(), and not the other mentions that produce diagnostics in the editor. Something like:
const selectedDiagnostic = vscode.languages.getSelectedDiagnostic();
Is there a way to retrieve in my code only the selected diagnostic?
In the CodeActionProvider in the method provideCodeActions the diagnostic is in the context parameter