Skip to content

Commit bbeefae

Browse files
committed
refactor(stepfunctions): replace vscode.openWith with openWithWorkflowStudio
1 parent b467251 commit bbeefae

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

packages/core/src/stepFunctions/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const previewStateMachineCommand = Commands.declare(
7575
throw new ToolkitError('No active text editor or document found')
7676
}
7777

78-
await vscode.commands.executeCommand('vscode.openWith', input, WorkflowStudioEditorProvider.viewType, {
78+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(input, {
7979
preserveFocus: true,
8080
viewColumn: vscode.ViewColumn.Beside,
8181
})

packages/core/src/stepFunctions/commands/downloadStateMachineDefinition.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,10 @@ export async function downloadStateMachineDefinition(params: {
4040
})
4141

4242
const textEditor = await vscode.window.showTextDocument(doc)
43-
await vscode.commands.executeCommand(
44-
'vscode.openWith',
45-
textEditor.document.uri,
46-
WorkflowStudioEditorProvider.viewType,
47-
{
48-
preserveFocus: true,
49-
viewColumn: vscode.ViewColumn.Beside,
50-
}
51-
)
43+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(textEditor.document.uri, {
44+
preserveFocus: true,
45+
viewColumn: vscode.ViewColumn.Beside,
46+
})
5247
} else {
5348
const wsPath = vscode.workspace.workspaceFolders
5449
? vscode.workspace.workspaceFolders[0].uri.fsPath

packages/core/src/stepFunctions/workflowStudio/activation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function activate(): Promise<void> {
1717
// Open the file with Workflow Studio editor in a new tab, or focus on the tab with WFS if it is already open
1818
globals.context.subscriptions.push(
1919
Commands.register('aws.stepfunctions.openWithWorkflowStudio', async (uri: vscode.Uri) => {
20-
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType)
20+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(uri)
2121
})
2222
)
2323

@@ -26,7 +26,7 @@ export async function activate(): Promise<void> {
2626
globals.context.subscriptions.push(
2727
Commands.register('aws.stepfunctions.switchToWorkflowStudio', async (uri: vscode.Uri) => {
2828
await vscode.commands.executeCommand('workbench.action.closeActiveEditor')
29-
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType)
29+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(uri)
3030
})
3131
)
3232
}

packages/core/src/stepFunctions/workflowStudio/workflowStudioEditorProvider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ let clientId = ''
3131
export class WorkflowStudioEditorProvider implements vscode.CustomTextEditorProvider {
3232
public static readonly viewType = 'workflowStudio.asl'
3333

34+
public static async openWithWorkflowStudio(
35+
uri: vscode.Uri,
36+
params?: Parameters<typeof vscode.window.createWebviewPanel>[2]
37+
) {
38+
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType, params)
39+
}
40+
3441
/**
3542
* Registers a new custom editor provider for asl files.
3643
* @remarks This should only be called once per extension.

0 commit comments

Comments
 (0)