adds handling for when we have ranges and diagnostics in quick fixes (#204421)

adds handling for when we have ranges and diagnostics
This commit is contained in:
Justin Chen 2024-02-05 14:02:29 -08:00 committed by GitHub
parent 4d3db486c2
commit 1f507c5474
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -308,7 +308,10 @@ export class CodeActionController extends Disposable implements IEditorContribut
const diagnostics = action.action.diagnostics;
currentDecorations.clear();
if (ranges && ranges.length > 0) {
const decorations: IModelDeltaDecoration[] = ranges.map(range => ({ range, options: CodeActionController.DECORATION }));
// Handles case for `fix all` where there are multiple diagnostics.
const decorations: IModelDeltaDecoration[] = (diagnostics && diagnostics?.length > 1)
? diagnostics.map(diagnostic => ({ range: diagnostic, options: CodeActionController.DECORATION }))
: ranges.map(range => ({ range, options: CodeActionController.DECORATION }));
currentDecorations.set(decorations);
} else if (diagnostics && diagnostics.length > 0) {
const decorations: IModelDeltaDecoration[] = diagnostics.map(diagnostic => ({ range: diagnostic, options: CodeActionController.DECORATION }));