Skip to content

Commit

Permalink
vscode: add support for valueSelection in InputBox (#12050)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
Co-authored-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
jonah-iden and paul-marechal authored Jan 13, 2023
1 parent 2d08d88 commit 72e70c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/plugin-ext/src/plugin/quick-open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ export class InputBoxExt extends QuickInputExt implements theia.InputBox {

private _password: boolean;
private _prompt: string | undefined;
private _valueSelection: readonly [number, number] | undefined;
private _validationMessage: string | undefined;

constructor(
Expand Down Expand Up @@ -576,6 +577,15 @@ export class InputBoxExt extends QuickInputExt implements theia.InputBox {
this.update({ prompt });
}

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

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

get validationMessage(): string | undefined {
return this._validationMessage;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5415,6 +5415,17 @@ export module '@theia/plugin' {
*/
password: boolean;

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

/**
* An event signaling when the value has changed.
*/
Expand Down

0 comments on commit 72e70c1

Please sign in to comment.