Skip to content

Commit db941d5

Browse files
Copilotrijesha
andcommitted
Optimize WorkspaceSetupFromCurrentDirectory by moving switch logic into westConfig
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
1 parent d1c68d3 commit db941d5

File tree

1 file changed

+15
-37
lines changed

1 file changed

+15
-37
lines changed

src/setup_utilities/workspace-setup.ts

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -348,45 +348,14 @@ export async function workspaceSetupFromCurrentDirectory(context: vscode.Extensi
348348
return false;
349349
}
350350

351-
let westSelection: WestLocation | undefined = undefined;
352-
353-
switch (westConfigResult.option) {
354-
case 'use-west-folder':
355-
// .west folder exists, no additional setup needed
356-
output.appendLine("[SETUP] Using existing .west folder");
357-
break;
358-
359-
case 'use-west-yml':
360-
// Use selected west.yml file
361-
if (westConfigResult.selectedWestPath) {
362-
westSelection = {
363-
path: westConfigResult.selectedWestPath,
364-
failed: false,
365-
gitRepo: "",
366-
additionalArgs: "",
367-
};
368-
output.appendLine(`[SETUP] Using west.yml from: ${westConfigResult.selectedWestPath}`);
369-
}
370-
break;
371-
372-
case 'create-new-west-yml':
373-
// Use west selector result
374-
westSelection = westConfigResult.westSelection;
375-
output.appendLine("[SETUP] Using new west.yml configuration");
376-
break;
377-
378-
case 'use-external-installation':
379-
// Handle external installation
380-
if (westConfigResult.externalInstallPath) {
381-
return await workspaceSetupOutOfTree(context, wsConfig, globalConfig);
382-
}
383-
break;
384-
385-
default:
386-
vscode.window.showErrorMessage("Invalid west configuration option");
387-
return false;
351+
// Handle external installation case
352+
if (westConfigResult.useExternalInstallation) {
353+
return await workspaceSetupOutOfTree(context, wsConfig, globalConfig);
388354
}
389355

356+
// Use the westSelection prepared by westConfig
357+
const westSelection = westConfigResult.westSelection;
358+
390359
await setSetupState(context, wsConfig, globalConfig, installDir);
391360

392361
// Run post-setup process
@@ -750,6 +719,7 @@ export interface WestConfigResult {
750719
selectedWestPath?: string;
751720
westSelection?: WestLocation;
752721
externalInstallPath?: string;
722+
useExternalInstallation?: boolean;
753723
}
754724

755725
/**
@@ -864,6 +834,7 @@ export async function westConfig(
864834
case 'use-west-folder':
865835
// .west folder already exists, nothing more to do
866836
result.option = 'use-west-folder';
837+
result.westSelection = undefined; // No west selection needed for existing .west folder
867838
output.appendLine(`[WEST CONFIG] Using existing .west folder`);
868839
break;
869840

@@ -875,6 +846,12 @@ export async function westConfig(
875846
}
876847
result.selectedWestPath = selectedWestPath;
877848
result.option = 'use-west-yml';
849+
result.westSelection = {
850+
path: selectedWestPath,
851+
failed: false,
852+
gitRepo: "",
853+
additionalArgs: "",
854+
};
878855
output.appendLine(`[WEST CONFIG] Selected west.yml from: ${selectedWestPath}`);
879856
break;
880857

@@ -909,6 +886,7 @@ export async function westConfig(
909886

910887
result.externalInstallPath = selectedInstall.detail;
911888
result.option = 'use-external-installation';
889+
result.useExternalInstallation = true;
912890
output.appendLine(`[WEST CONFIG] Selected external installation: ${selectedInstall.detail}`);
913891
break;
914892

0 commit comments

Comments
 (0)