Skip to content

Commit

Permalink
feat: support VSCode API: inputBox.valueSelection (#4145)
Browse files Browse the repository at this point in the history
* chore: add valueSelection typings

* feat: support InputBox.valueSelection
  • Loading branch information
bk1012 authored Nov 7, 2024
1 parent ceb3fb9 commit 926108b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/extension/src/hosted/api/vscode/ext.host.quickopen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ abstract class ExtQuickInput implements vscode.InputBox {
abstract type: QuickInputType;

private _value: string;
private _valueSelection: [number, number] | undefined;
private _placeholder: string | undefined;
private _password: boolean;
private _buttons: vscode.QuickInputButton[];
Expand Down Expand Up @@ -565,6 +566,15 @@ abstract class ExtQuickInput implements vscode.InputBox {
this.update({ value });
}

get valueSelection(): [number, number] | undefined {
return this._valueSelection;
}

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

get totalSteps(): number | undefined {
return this._totalSteps;
}
Expand Down
1 change: 0 additions & 1 deletion packages/quick-open/src/browser/quick-open.widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class QuickOpenWidget implements IQuickOpenWidget {
@observable
private _valueSelection?: [number, number];

@computed
get valueSelection() {
return this._valueSelection;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/types/vscode/typings/vscode.quickpick.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ declare module 'vscode' {
*/
value: string;

/**
* 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;

/**
* Optional placeholder in the filter text.
*/
Expand Down

0 comments on commit 926108b

Please sign in to comment.