diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index 1a188fb57d86b6..57b3fd96d4d4b9 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -36,16 +36,18 @@ export interface Diagnostic { column: number; }; fix: { - content: string; message: string | null; - location: { - row: number; - column: number; - }; - end_location: { - row: number; - column: number; - }; + edits: { + content: string; + location: { + row: number; + column: number; + }; + end_location: { + row: number; + column: number; + }; + }[]; } | null; }; "#; diff --git a/playground/src/Editor/SourceEditor.tsx b/playground/src/Editor/SourceEditor.tsx index f33533d77f7d41..da7677d1ad8286 100644 --- a/playground/src/Editor/SourceEditor.tsx +++ b/playground/src/Editor/SourceEditor.tsx @@ -57,27 +57,27 @@ export default function SourceEditor({ .filter((check) => check.fix) .map((check) => ({ title: check.fix - ? `${check.code}: ${check.fix.message}` ?? `Fix ${check.code}` + ? check.fix.message + ? `${check.code}: ${check.fix.message}` + : `Fix ${check.code}` : "Autofix", id: `fix-${check.code}`, kind: "quickfix", edit: check.fix ? { - edits: [ - { - resource: model.uri, - versionId: model.getVersionId(), - edit: { - range: { - startLineNumber: check.fix.location.row, - startColumn: check.fix.location.column + 1, - endLineNumber: check.fix.end_location.row, - endColumn: check.fix.end_location.column + 1, - }, - text: check.fix.content, + edits: check.fix.edits.map((edit) => ({ + resource: model.uri, + versionId: model.getVersionId(), + edit: { + range: { + startLineNumber: edit.location.row, + startColumn: edit.location.column + 1, + endLineNumber: edit.end_location.row, + endColumn: edit.end_location.column + 1, }, + text: edit.content, }, - ], + })), } : undefined, }));