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 ++-- editors/code/src/source_change.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'editors/code') 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); }; } diff --git a/editors/code/src/source_change.ts b/editors/code/src/source_change.ts index a336269ba..b19d325d5 100644 --- a/editors/code/src/source_change.ts +++ b/editors/code/src/source_change.ts @@ -9,7 +9,7 @@ export interface SourceChange { cursorPosition?: lc.TextDocumentPositionParams; } -export async function applySourceChange(ctx: Ctx, change: SourceChange) { +async function applySelectedSourceChange(ctx: Ctx, change: SourceChange) { const client = ctx.client; if (!client) return; @@ -55,3 +55,13 @@ export async function applySourceChange(ctx: Ctx, change: SourceChange) { ); } } + +export async function applySourceChange(ctx: Ctx, change: SourceChange, alternativeChanges: SourceChange[] | undefined) { + if (alternativeChanges !== undefined && alternativeChanges.length > 0) { + const selectedChange = await vscode.window.showQuickPick([change, ...alternativeChanges]); + if (!selectedChange) return; + await applySelectedSourceChange(ctx, selectedChange); + } else { + await applySelectedSourceChange(ctx, change); + } +} -- cgit v1.2.3