-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Description
Same as #111944 but for VS Code extensions (It's not obvious to me if original issue is the literal duplicate and was closed due to the inactivity, or if it was meant to be used only inside VS Code codebase (at least I see valueSelection attribute available in the corresponding file for VS Code))
vscode/src/vs/platform/quickinput/common/quickInput.ts
Lines 586 to 589 in a38d2d0
| /** | |
| * The selection range for the value in the input. | |
| */ | |
| valueSelection: Readonly<[number, number]> | undefined; |
Copying the description from the original description:
Currently there seem to be two text selection modes for QuickPick values:
If quickPick.value is set before quickPick.show() is called, then the value (text) will be selected when the quick pick becomes visible, and typing a character will replace the input text unless the selection is changed first.
If quickPick.value is set after quickPick.show() is called, then the caret will be placed at the end of the text value, ready for more characters to be typed at the end.
These selection modes seem to be undocumented.
It would be useful to be able to select a range of text rather than all or nothing.This would allow more powerful text input control by extensions. For example, it could be used to facilitate commands with multiple auto-completed arguments. An example API could be something like
const input = vscode.window.createQuickPick();
input.value = "a text string";
input.setValueSelection(2, 6);
input.show()
The quick pick would be displayed with the word "text" selected.