diff --git a/README.md b/README.md index 1b33711..384571b 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ After you install the CodeSwing extension, you can create new swings at any time - `CodeSwing: New Swing in Directory...` - Creates a swing in a local directory, which allows you to re-open it later, and easily share it with others (e.g. store it in a GitHub repo). +- `CodeSwing: New Swing in New Window...` - Creates a new temporary swing in a new VS Code window. + After creating a swing, your editor layout will be automatically setup to accomodate the needs of the selected template. Furthermore, if you open a directory that represents a swing, or you run the `CodeSwing: Open Swing...` command, then the selected swing will be automatically launched. ### Language Support @@ -265,6 +267,8 @@ When you install CodeSwing, the following commands are available from the comman - `CodeSwing: Open Swing in New Windows...` - Opens a swing in a new VS Code window. +- `CodeSwing: New Swing in New Window...` - Creates a new temporary swing in a new VS Code window. + - `CodeSwing: Set OpenAI API Key` - Configures the OpenAI API key that is used to support generating AI swings. Additionally, when you have a swing currently open, the following commands are available: diff --git a/package.json b/package.json index c1d0300..e76716f 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,11 @@ "command": "codeswing.uploadSwingFile", "title": "Upload File(s)", "icon": "$(cloud-upload)" + }, + { + "command": "codeswing.newSwingInNewWindow", + "title": "New Swing in New Window...", + "category": "CodeSwing" } ], "views": { diff --git a/src/creation/index.ts b/src/creation/index.ts index 981db96..8d55bac 100644 --- a/src/creation/index.ts +++ b/src/creation/index.ts @@ -49,7 +49,8 @@ async function getTemplates(): Promise { export async function newSwing( uri: vscode.Uri | ((files: SwingFile[]) => Promise), - title: string = "Create new swing" + title: string = "Create new swing", + openInNewWindow: boolean = false ) { const quickPick = vscode.window.createQuickPick(); quickPick.title = title; @@ -118,7 +119,7 @@ export async function newSwing( }, ]; await withProgress("Creating swing...", async () => - newSwingFromTemplate(template.files!, uri) + newSwingFromTemplate(template.files!, uri, openInNewWindow) ); await storage.addTemplateToMRU(template.label); @@ -145,7 +146,8 @@ async function synthesizeTemplate( async function newSwingFromTemplate( files: SwingFile[], - uri: vscode.Uri | ((files: SwingFile[]) => Promise) + uri: vscode.Uri | ((files: SwingFile[]) => Promise), + openInNewWindow: boolean = false ) { const manifest = files.find((file) => file.filename === SWING_FILE); if (!manifest) { @@ -184,7 +186,13 @@ async function newSwingFromTemplate( swingUri = uri; } - openSwing(swingUri); + if (openInNewWindow) { + vscode.commands.executeCommand("vscode.openFolder", swingUri, { + forceNewWindow: true, + }); + } else { + openSwing(swingUri); + } } async function promptForGalleryConfiguration( @@ -319,6 +327,16 @@ export function registerCreationModule( ) ); + context.subscriptions.push( + vscode.commands.registerCommand( + `${EXTENSION_NAME}.newSwingInNewWindow`, + async () => { + const uri = await createSwingDirectory(); + newSwing(uri, "Create swing in new window", true); + } + ) + ); + initializeStorage(context, syncKeys); api.newSwing = newSwing;