Skip to content

Commit 549fd1a

Browse files
Copiloteleanorjboyd
andcommitted
Fix: Open file browser at workspace root when selecting interpreter path
- Added defaultUri parameter to showOpenDialog to open at current workspace - Updated all related unit tests to include defaultUri in expected parameters - Added new test case to verify workspace URI is used as defaultUri Co-authored-by: eleanorjboyd <[email protected]>
1 parent f236b9f commit 549fd1a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem
554554
openLabel: InterpreterQuickPickList.browsePath.openButtonLabel,
555555
canSelectMany: false,
556556
title: InterpreterQuickPickList.browsePath.title,
557+
defaultUri: state.workspace,
557558
});
558559
if (uris && uris.length > 0) {
559560
state.path = uris[0].fsPath;

src/test/configuration/interpreterSelector/commands/setInterpreter.unit.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ suite('Set Interpreter Command', () => {
10521052
openLabel: InterpreterQuickPickList.browsePath.openButtonLabel,
10531053
canSelectMany: false,
10541054
title: InterpreterQuickPickList.browsePath.title,
1055+
defaultUri: undefined,
10551056
};
10561057
const multiStepInput = TypeMoq.Mock.ofType<IMultiStepInput<InterpreterStateArgs>>();
10571058
multiStepInput.setup((i) => i.showQuickPick(TypeMoq.It.isAny())).returns(() => Promise.resolve(items[0]));
@@ -1073,6 +1074,27 @@ suite('Set Interpreter Command', () => {
10731074
openLabel: InterpreterQuickPickList.browsePath.openButtonLabel,
10741075
canSelectMany: false,
10751076
title: InterpreterQuickPickList.browsePath.title,
1077+
defaultUri: undefined,
1078+
};
1079+
multiStepInput.setup((i) => i.showQuickPick(TypeMoq.It.isAny())).returns(() => Promise.resolve(items[0]));
1080+
appShell.setup((a) => a.showOpenDialog(expectedParams)).verifiable(TypeMoq.Times.once());
1081+
platformService.setup((p) => p.isWindows).returns(() => false);
1082+
1083+
await setInterpreterCommand._enterOrBrowseInterpreterPath(multiStepInput.object, state).ignoreErrors();
1084+
1085+
appShell.verifyAll();
1086+
});
1087+
1088+
test('If `Browse...` option is selected with workspace, file browser opens at workspace root', async () => {
1089+
const workspaceUri = Uri.parse('file:///workspace/root');
1090+
const state: InterpreterStateArgs = { path: undefined, workspace: workspaceUri };
1091+
const multiStepInput = TypeMoq.Mock.ofType<IMultiStepInput<InterpreterStateArgs>>();
1092+
const expectedParams = {
1093+
filters: undefined,
1094+
openLabel: InterpreterQuickPickList.browsePath.openButtonLabel,
1095+
canSelectMany: false,
1096+
title: InterpreterQuickPickList.browsePath.title,
1097+
defaultUri: workspaceUri,
10761098
};
10771099
multiStepInput.setup((i) => i.showQuickPick(TypeMoq.It.isAny())).returns(() => Promise.resolve(items[0]));
10781100
appShell.setup((a) => a.showOpenDialog(expectedParams)).verifiable(TypeMoq.Times.once());
@@ -1126,6 +1148,7 @@ suite('Set Interpreter Command', () => {
11261148
openLabel: InterpreterQuickPickList.browsePath.openButtonLabel,
11271149
canSelectMany: false,
11281150
title: InterpreterQuickPickList.browsePath.title,
1151+
defaultUri: undefined,
11291152
};
11301153
multiStepInput
11311154
.setup((i) => i.showQuickPick(TypeMoq.It.isAny()))

0 commit comments

Comments
 (0)