-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Description
Currently there seem to be two text selection modes for QuickPick values:
- If
quickPick.valueis set beforequickPick.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.valueis set afterquickPick.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.
Variant: call with a single argument to select from start index to the end of the value:
input.setValueSelection(2);
The argument semantics are modeled after the JavaScript Array slice() method. Negative indices would be nice to have, but not required. A no-argument variant could also be provided (selecting the entire value), although this is already possible via other means, so not necessary.