diff --git a/src/extension.ts b/src/extension.ts index 3561b40..92618f6 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -154,9 +154,12 @@ export async function runMageforgeCommand( const themes = await themesProvider.getThemeCodes(); if (themes.length > 0) { const picked = await vscode.window.showQuickPick(themes, { - placeHolder: 'Select a theme (or press Esc to run interactively)', + placeHolder: 'Select a theme', canPickMany: false, }); + if (!picked) { + return; + } themeCode = picked; } } diff --git a/src/test/unit/extension.test.ts b/src/test/unit/extension.test.ts index 339f807..7223c8c 100644 --- a/src/test/unit/extension.test.ts +++ b/src/test/unit/extension.test.ts @@ -104,6 +104,22 @@ suite('extension.ts unit tests', () => { assert.strictEqual(terminals[0].name, 'MageForge: Theme: Watch'); }); + test('does nothing when user cancels theme selection', async () => { + const { runMageforgeCommand } = loadExtension(mockMagento); + const themesProvider = createThemesProvider(['Magento/luma']); + + await runMageforgeCommand( + { + id: 'mageforge.theme.build', + cliCommand: 'mageforge:theme:build', + acceptsThemes: true, + } as MageforgeCommand, + themesProvider, + ); + + assert.strictEqual(terminals.length, 0); + }); + test('does nothing when no Magento root is found', async () => { mockMagento.getMagentoRoot = () => undefined; const { runMageforgeCommand } = loadExtension(mockMagento);