diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/commands/index.ts | 17 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 | ||||
-rw-r--r-- | editors/code/src/source_change.ts | 12 |
3 files changed, 17 insertions, 13 deletions
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 { | |||
34 | } | 34 | } |
35 | 35 | ||
36 | function applySourceChange(ctx: Ctx): Cmd { | 36 | function applySourceChange(ctx: Ctx): Cmd { |
37 | return async (change: sourceChange.SourceChange, alternativeChanges: sourceChange.SourceChange[] | undefined) => { | 37 | return async (change: sourceChange.SourceChange) => { |
38 | sourceChange.applySourceChange(ctx, change, alternativeChanges); | 38 | sourceChange.applySourceChange(ctx, change); |
39 | }; | ||
40 | } | ||
41 | |||
42 | function selectAndApplySourceChange(ctx: Ctx): Cmd { | ||
43 | return async (changes: sourceChange.SourceChange[]) => { | ||
44 | if (changes.length === 1) { | ||
45 | await sourceChange.applySourceChange(ctx, changes[0]); | ||
46 | } else if (changes.length > 0) { | ||
47 | const selectedChange = await vscode.window.showQuickPick(changes); | ||
48 | if (!selectedChange) return; | ||
49 | await sourceChange.applySourceChange(ctx, selectedChange); | ||
50 | } | ||
39 | }; | 51 | }; |
40 | } | 52 | } |
41 | 53 | ||
@@ -59,5 +71,6 @@ export { | |||
59 | runSingle, | 71 | runSingle, |
60 | showReferences, | 72 | showReferences, |
61 | applySourceChange, | 73 | applySourceChange, |
74 | selectAndApplySourceChange, | ||
62 | reload | 75 | reload |
63 | }; | 76 | }; |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 430ad31b4..0494ccf63 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -26,6 +26,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
26 | ctx.registerCommand('runSingle', commands.runSingle); | 26 | ctx.registerCommand('runSingle', commands.runSingle); |
27 | ctx.registerCommand('showReferences', commands.showReferences); | 27 | ctx.registerCommand('showReferences', commands.showReferences); |
28 | ctx.registerCommand('applySourceChange', commands.applySourceChange); | 28 | ctx.registerCommand('applySourceChange', commands.applySourceChange); |
29 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); | ||
29 | 30 | ||
30 | if (ctx.config.enableEnhancedTyping) { | 31 | if (ctx.config.enableEnhancedTyping) { |
31 | ctx.overrideCommand('type', commands.onEnter); | 32 | ctx.overrideCommand('type', commands.onEnter); |
diff --git a/editors/code/src/source_change.ts b/editors/code/src/source_change.ts index b19d325d5..a336269ba 100644 --- a/editors/code/src/source_change.ts +++ b/editors/code/src/source_change.ts | |||
@@ -9,7 +9,7 @@ export interface SourceChange { | |||
9 | cursorPosition?: lc.TextDocumentPositionParams; | 9 | cursorPosition?: lc.TextDocumentPositionParams; |
10 | } | 10 | } |
11 | 11 | ||
12 | async function applySelectedSourceChange(ctx: Ctx, change: SourceChange) { | 12 | export async function applySourceChange(ctx: Ctx, change: SourceChange) { |
13 | const client = ctx.client; | 13 | const client = ctx.client; |
14 | if (!client) return; | 14 | if (!client) return; |
15 | 15 | ||
@@ -55,13 +55,3 @@ async function applySelectedSourceChange(ctx: Ctx, change: SourceChange) { | |||
55 | ); | 55 | ); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | |||
59 | export async function applySourceChange(ctx: Ctx, change: SourceChange, alternativeChanges: SourceChange[] | undefined) { | ||
60 | if (alternativeChanges !== undefined && alternativeChanges.length > 0) { | ||
61 | const selectedChange = await vscode.window.showQuickPick([change, ...alternativeChanges]); | ||
62 | if (!selectedChange) return; | ||
63 | await applySelectedSourceChange(ctx, selectedChange); | ||
64 | } else { | ||
65 | await applySelectedSourceChange(ctx, change); | ||
66 | } | ||
67 | } | ||