Skip to content

Commit 966100d

Browse files
committed
Only accept WorkspaceEdit, #34664
1 parent eb1f87c commit 966100d

File tree

4 files changed

+9
-23
lines changed

4 files changed

+9
-23
lines changed

extensions/typescript/src/features/quickFixProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
106106
private getCommandForAction(action: Proto.CodeAction): vscode.CodeAction {
107107
return {
108108
title: action.description,
109-
edits: getEditForCodeAction(this.client, action),
109+
edit: getEditForCodeAction(this.client, action),
110110
command: action.commands ? {
111111
command: ApplyCodeActionCommand.ID,
112112
arguments: [action],
@@ -115,4 +115,4 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
115115
diagnostics: []
116116
};
117117
}
118-
}
118+
}

src/vs/vscode.proposed.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,21 @@ declare module 'vscode' {
210210
title: string;
211211

212212
/**
213-
* Optional edit that performs the code action.
213+
* A workspace edit this code action performs.
214214
*
215-
* Either `command` or `edits` must be provided for a `CodeAction`.
215+
* *Note* that either an [`edit`](CodeAction#edit) or a [`command`](CodeAction#command) must be supplied.
216216
*/
217-
edits?: TextEdit[] | WorkspaceEdit;
217+
edit?: WorkspaceEdit;
218218

219219
/**
220220
* Diagnostics that this code action resolves.
221221
*/
222222
diagnostics?: Diagnostic[];
223223

224224
/**
225-
* Optional command that performs the code action.
225+
* A command this code action performs.
226226
*
227-
* Executed after `edits` if any edits are provided. Either `command` or `edits` must be provided for a `CodeAction`.
227+
* *Note* that either an [`edit`](CodeAction#edit) or a [`command`](CodeAction#command) must be supplied.
228228
*/
229229
command?: Command;
230230

@@ -237,7 +237,7 @@ declare module 'vscode' {
237237
* @param title The title of the code action.
238238
* @param edits The edit of the code action.
239239
*/
240-
constructor(title: string, edits?: TextEdit[] | WorkspaceEdit);
240+
constructor(title: string, edit?: WorkspaceEdit);
241241
}
242242

243243
export interface CodeActionProvider {

src/vs/workbench/api/node/extHostLanguageFeatures.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ class CodeActionAdapter {
314314
title: candidate.title,
315315
command: candidate.command && this._commands.toInternal(candidate.command),
316316
diagnostics: candidate.diagnostics && candidate.diagnostics.map(DiagnosticCollection.toMarkerData),
317-
edits: Array.isArray(candidate.edits)
318-
? TypeConverters.WorkspaceEdit.fromTextEdits(resource, candidate.edits)
319-
: candidate.edits && TypeConverters.WorkspaceEdit.from(candidate.edits),
317+
edits: candidate.edit && TypeConverters.WorkspaceEdit.from(candidate.edit),
320318
});
321319
}
322320
}

src/vs/workbench/api/node/extHostTypeConverters.ts

-12
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,6 @@ export namespace WorkspaceEdit {
241241
return result;
242242
}
243243

244-
export function fromTextEdits(uri: vscode.Uri, textEdits: vscode.TextEdit[]): modes.WorkspaceEdit {
245-
const result: modes.WorkspaceEdit = { edits: [] };
246-
for (let textEdit of textEdits) {
247-
result.edits.push({
248-
resource: uri,
249-
newText: textEdit.newText,
250-
range: fromRange(textEdit.range)
251-
});
252-
}
253-
return result;
254-
}
255-
256244
export function to(value: modes.WorkspaceEdit) {
257245
const result = new types.WorkspaceEdit();
258246
for (const edit of value.edits) {

0 commit comments

Comments
 (0)