Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for adding value selection in QuickPick for extension API #233275

3 changes: 3 additions & 0 deletions src/vs/platform/extensions/common/extensionsApiProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ const _allApiProposals = {
tunnels: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tunnels.d.ts',
},
valueSelectionInQuickPick: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.valueSelectionInQuickPick.d.ts',
},
workspaceTrust: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.workspaceTrust.d.ts',
}
Expand Down
20 changes: 10 additions & 10 deletions src/vs/workbench/api/common/extHostQuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
private _busy = false;
private _ignoreFocusOut = true;
private _value = '';
private _valueSelection: readonly [number, number] | undefined = undefined;
private _placeholder: string | undefined;
private _buttons: QuickInputButton[] = [];
private _handlesToButtons = new Map<number, QuickInputButton>();
Expand Down Expand Up @@ -367,6 +368,15 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
this.update({ value });
}

get valueSelection() {
return this._valueSelection;
}

set valueSelection(valueSelection: readonly [number, number] | undefined) {
this._valueSelection = valueSelection;
this.update({ valueSelection });
}

get placeholder() {
return this._placeholder;
}
Expand Down Expand Up @@ -713,7 +723,6 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx

private _password = false;
private _prompt: string | undefined;
private _valueSelection: readonly [number, number] | undefined;
private _validationMessage: string | InputBoxValidationMessage | undefined;

constructor(extension: IExtensionDescription, onDispose: () => void) {
Expand All @@ -739,15 +748,6 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
this.update({ prompt });
}

get valueSelection() {
return this._valueSelection;
}

set valueSelection(valueSelection: readonly [number, number] | undefined) {
this._valueSelection = valueSelection;
this.update({ valueSelection });
}

get validationMessage() {
return this._validationMessage;
}
Expand Down
21 changes: 21 additions & 0 deletions src/vscode-dts/vscode.proposed.valueSelectionInQuickPick.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {
// @CrafterKolyan https://github.com/microsoft/vscode/issues/233274

export interface QuickPick<T> {
/**
* Selection range in the input value. Defined as tuple of two number where the
* first is the inclusive start index and the second the exclusive end index. When
* `undefined` the whole pre-filled value will be selected, when empty (start equals end)
* only the cursor will be set, otherwise the defined range will be selected.
*
* This property does not get updated when the user types or makes a selection,
* but it can be updated by the extension.
*/
valueSelection: readonly [number, number] | undefined;
}
}
Loading