Skip to content

Commit e8a490d

Browse files
Kartik Rajeleanorjboyd
Kartik Raj
authored andcommitted
Allow to specify title and placeholder in API for interpreter quickpick (microsoft#19896)
For microsoft#19891
1 parent 5702b85 commit e8a490d

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/client/common/utils/multiStepInput.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface IQuickPickParameters<T extends QuickPickItem, E = any> {
4747
canGoBack?: boolean;
4848
items: T[];
4949
activeItem?: T | Promise<T>;
50-
placeholder: string;
50+
placeholder: string | undefined;
5151
customButtonSetups?: QuickInputButtonSetup[];
5252
matchOnDescription?: boolean;
5353
matchOnDetail?: boolean;

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

+16-7
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem
128128
input: IMultiStepInput<InterpreterStateArgs>,
129129
state: InterpreterStateArgs,
130130
filter?: (i: PythonEnvironment) => boolean,
131+
params?: { placeholder?: string | null; title?: string | null },
131132
): Promise<void | InputStep<InterpreterStateArgs>> {
132133
// If the list is refreshing, it's crucial to maintain sorting order at all
133134
// times so that the visible items do not change.
@@ -138,19 +139,26 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem
138139
this.configurationService.getSettings(state.workspace).pythonPath,
139140
state.workspace ? state.workspace.fsPath : undefined,
140141
);
142+
const placeholder =
143+
params?.placeholder === null
144+
? undefined
145+
: params?.placeholder ??
146+
localize(
147+
'InterpreterQuickPickList.quickPickListPlaceholder',
148+
'Selected Interpreter: {0}',
149+
currentInterpreterPathDisplay,
150+
);
151+
const title =
152+
params?.title === null ? undefined : params?.title ?? InterpreterQuickPickList.browsePath.openButtonLabel;
141153
const selection = await input.showQuickPick<QuickPickType, IQuickPickParameters<QuickPickType>>({
142-
placeholder: localize(
143-
'InterpreterQuickPickList.quickPickListPlaceholder',
144-
'Selected Interpreter: {0}',
145-
currentInterpreterPathDisplay,
146-
),
154+
placeholder,
147155
items: suggestions,
148156
sortByLabel: !preserveOrderWhenFiltering,
149157
keepScrollPosition: true,
150158
activeItem: this.getActiveItem(state.workspace, suggestions), // Use a promise here to ensure quickpick is initialized synchronously.
151159
matchOnDetail: true,
152160
matchOnDescription: true,
153-
title: InterpreterQuickPickList.browsePath.openButtonLabel,
161+
title,
154162
customButtonSetups: [
155163
{
156164
button: this.refreshButton,
@@ -503,10 +511,11 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem
503511
public async getInterpreterViaQuickPick(
504512
workspace: Resource,
505513
filter: ((i: PythonEnvironment) => boolean) | undefined,
514+
params?: { placeholder?: string | null; title?: string | null },
506515
): Promise<string | undefined> {
507516
const interpreterState: InterpreterStateArgs = { path: undefined, workspace };
508517
const multiStep = this.multiStepFactory.create<InterpreterStateArgs>();
509-
await multiStep.run((input, s) => this._pickInterpreter(input, s, filter), interpreterState);
518+
await multiStep.run((input, s) => this._pickInterpreter(input, s, filter, params), interpreterState);
510519
return interpreterState.path;
511520
}
512521

src/client/interpreter/configuration/types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,15 @@ export interface IInterpreterQuickPick {
7171
getInterpreterViaQuickPick(
7272
workspace: Resource,
7373
filter?: (i: PythonEnvironment) => boolean,
74+
params?: {
75+
/**
76+
* Specify `null` if a placeholder is not required.
77+
*/
78+
placeholder?: string | null;
79+
/**
80+
* Specify `null` if a title is not required.
81+
*/
82+
title?: string | null;
83+
},
7484
): Promise<string | undefined>;
7585
}

0 commit comments

Comments
 (0)