Skip to content

Commit e7678f5

Browse files
committed
handle callback correctly for back button
1 parent 535edca commit e7678f5

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

src/features/creators/creationHelpers.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ import { EnvironmentManagers, InternalEnvironmentManager } from '../../internal.
1212
*/
1313
export async function promptForVenv(callback: () => void): Promise<boolean | undefined> {
1414
try {
15+
const venvChoice = await showQuickPickWithButtons([{ label: 'Yes' }, { label: 'No' }], {
16+
placeHolder: 'Would you like to create a new virtual environment for this project?',
17+
ignoreFocusOut: true,
18+
showBackButton: true,
19+
});
20+
if (!venvChoice) {
21+
return undefined;
22+
}
23+
if (Array.isArray(venvChoice)) {
24+
// Should not happen for single selection, but handle just in case
25+
return venvChoice.some((item) => item.label === 'Yes');
26+
}
27+
return venvChoice.label === 'Yes';
1528
} catch (ex) {
1629
if (ex === QuickInputButtons.Back) {
1730
callback();
1831
}
1932
}
20-
const venvChoice = await showQuickPickWithButtons([{ label: 'Yes' }, { label: 'No' }], {
21-
placeHolder: 'Would you like to create a new virtual environment for this project?',
22-
ignoreFocusOut: true,
23-
showBackButton: true,
24-
});
25-
if (!venvChoice) {
26-
return undefined;
27-
}
28-
if (Array.isArray(venvChoice)) {
29-
// Should not happen for single selection, but handle just in case
30-
return venvChoice.some((item) => item.label === 'Yes');
31-
}
32-
return venvChoice.label === 'Yes';
3333
}
3434

3535
/**

src/features/creators/newPackageProject.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
isCopilotInstalled,
1010
manageCopilotInstructionsFile,
1111
manageLaunchJsonFile,
12-
promptForCopilotInstructions,
1312
promptForVenv,
1413
quickCreateNewVenv,
1514
replaceInFilesAndNames,
@@ -53,22 +52,14 @@ export class NewPackageProject implements PythonProjectCreator {
5352
}
5453
// Use helper to prompt for virtual environment creation
5554
const callback = () => {
56-
if (options) {
57-
return this.create(options);
58-
} else {
59-
return this.create({ name: packageName } as PythonProjectCreatorOptions);
60-
}
55+
return this.create(options);
6156
};
6257
createVenv = await promptForVenv(callback);
6358
if (createVenv === undefined) {
6459
return undefined;
6560
}
6661
if (isCopilotInstalled()) {
67-
const copilotResult = await promptForCopilotInstructions();
68-
if (copilotResult === undefined) {
69-
return undefined;
70-
}
71-
createCopilotInstructions = copilotResult === true;
62+
createCopilotInstructions = true;
7263
}
7364
}
7465

0 commit comments

Comments
 (0)