From 73dc8b6f06b49f4728a50e83781c361e9a8b3100 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 2 Jan 2020 01:39:01 +0200 Subject: Another attempt to add multiple edits --- editors/code/src/commands/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 9a1697dcb..0ff708b1f 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -34,8 +34,8 @@ function showReferences(ctx: Ctx): Cmd { } function applySourceChange(ctx: Ctx): Cmd { - return async (change: sourceChange.SourceChange) => { - sourceChange.applySourceChange(ctx, change); + return async (change: sourceChange.SourceChange, alternativeChanges: sourceChange.SourceChange[] | undefined) => { + sourceChange.applySourceChange(ctx, change, alternativeChanges); }; } -- cgit v1.2.3 From 78a21253b494e573885ac8336bff6e93b401046f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 12 Jan 2020 00:40:36 +0200 Subject: Apply the api design suggestions --- editors/code/src/commands/index.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 0ff708b1f..dc075aa82 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -34,8 +34,20 @@ function showReferences(ctx: Ctx): Cmd { } function applySourceChange(ctx: Ctx): Cmd { - return async (change: sourceChange.SourceChange, alternativeChanges: sourceChange.SourceChange[] | undefined) => { - sourceChange.applySourceChange(ctx, change, alternativeChanges); + return async (change: sourceChange.SourceChange) => { + sourceChange.applySourceChange(ctx, change); + }; +} + +function selectAndApplySourceChange(ctx: Ctx): Cmd { + return async (changes: sourceChange.SourceChange[]) => { + if (changes.length === 1) { + await sourceChange.applySourceChange(ctx, changes[0]); + } else if (changes.length > 0) { + const selectedChange = await vscode.window.showQuickPick(changes); + if (!selectedChange) return; + await sourceChange.applySourceChange(ctx, selectedChange); + } }; } @@ -59,5 +71,6 @@ export { runSingle, showReferences, applySourceChange, + selectAndApplySourceChange, reload }; -- cgit v1.2.3