Skip to content

Commit 7364047

Browse files
committed
Merge branch 'copilot/fix-125' of https://github.com/mylonics/zephyr-ide into copilot/fix-125
2 parents f52f88d + 3bff5cc commit 7364047

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

src/setup_utilities/workspace-setup.ts

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,35 @@ export async function workspaceSetupStandard(context: vscode.ExtensionContext, w
303303
return true;
304304
}
305305

306+
/**
307+
* Handle external installation configuration and setup
308+
*/
309+
async function handleExternalInstallation(
310+
context: vscode.ExtensionContext,
311+
wsConfig: WorkspaceConfig,
312+
globalConfig: GlobalConfig,
313+
westConfigResult: WestConfigResult
314+
): Promise<boolean> {
315+
const externalPath = westConfigResult.externalInstallPath!;
316+
const needsSetup = westConfigResult.externalInstallNeedsSetup;
317+
output.appendLine(`[SETUP] Using external installation: ${externalPath} (needsSetup=${needsSetup})`);
318+
319+
await setSetupState(context, wsConfig, globalConfig, externalPath);
320+
321+
if (needsSetup) {
322+
const extWestSelection = await westSelector(context, wsConfig);
323+
if (!extWestSelection || extWestSelection.failed) {
324+
vscode.window.showErrorMessage("External installation configuration cancelled or failed.");
325+
return false;
326+
}
327+
postWorkspaceSetup(context, wsConfig, globalConfig, externalPath, extWestSelection);
328+
} else {
329+
vscode.window.showInformationMessage(`Workspace linked to external Zephyr installation at: ${externalPath}`);
330+
}
331+
332+
return true;
333+
}
334+
306335
export async function workspaceSetupFromCurrentDirectory(context: vscode.ExtensionContext, wsConfig: WorkspaceConfig, globalConfig: GlobalConfig, giveExternalInstallOption: boolean, installDir?: string) {
307336
// Clear all context flags at start
308337
await clearWorkspaceSetupContextFlags(context, wsConfig);
@@ -317,7 +346,6 @@ export async function workspaceSetupFromCurrentDirectory(context: vscode.Extensi
317346
return false;
318347
}
319348

320-
321349
output.show();
322350
output.appendLine(
323351
`[SETUP] Setting up current directory as Zephyr IDE workspace: ${installDir}`
@@ -348,33 +376,12 @@ export async function workspaceSetupFromCurrentDirectory(context: vscode.Extensi
348376

349377
// Handle external installation case
350378
if (westConfigResult.useExternalInstallation) {
351-
const externalPath = westConfigResult.externalInstallPath!;
352-
const needsSetup = westConfigResult.externalInstallNeedsSetup;
353-
output.appendLine(`[SETUP] Using external installation: ${externalPath} (needsSetup=${needsSetup})`);
354-
355-
if (needsSetup) {
356-
await setSetupState(context, wsConfig, globalConfig, externalPath);
357-
const extWestSelection = await westSelector(context, wsConfig);
358-
if (!extWestSelection || extWestSelection.failed) {
359-
vscode.window.showErrorMessage("External installation configuration cancelled or failed.");
360-
return false;
361-
}
362-
postWorkspaceSetup(context, wsConfig, globalConfig, externalPath, extWestSelection);
363-
return true;
364-
} else {
365-
await setSetupState(context, wsConfig, globalConfig, externalPath);
366-
vscode.window.showInformationMessage(`Workspace linked to external Zephyr installation at: ${externalPath}`);
367-
return true;
368-
}
379+
return await handleExternalInstallation(context, wsConfig, globalConfig, westConfigResult);
369380
}
370381

371-
// Use the westSelection prepared by westConfig
372-
const westSelection = westConfigResult.westSelection;
373-
382+
// Handle local workspace setup
374383
await setSetupState(context, wsConfig, globalConfig, installDir);
375-
376-
// Run post-setup process
377-
postWorkspaceSetup(context, wsConfig, globalConfig, installDir, westSelection);
384+
postWorkspaceSetup(context, wsConfig, globalConfig, installDir, westConfigResult.westSelection);
378385
return true;
379386
}
380387

0 commit comments

Comments
 (0)