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

API to select character range of QuickPick input text value for VSCode extensions #233274

Closed
CrafterKolyan opened this issue Nov 7, 2024 · 0 comments · Fixed by #233275
Closed
Assignees
Labels
api-proposal feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan quick-pick Quick-pick widget issues
Milestone

Comments

@CrafterKolyan
Copy link
Contributor

CrafterKolyan commented Nov 7, 2024

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))

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

@CrafterKolyan CrafterKolyan changed the title API to select character range of QuickPick input text value (re-open) API to select character range of QuickPick input text value for VSCode extensions Nov 7, 2024
@TylerLeonhardt TylerLeonhardt added feature-request Request for new features or functionality quick-pick Quick-pick widget issues labels Nov 8, 2024
@TylerLeonhardt TylerLeonhardt modified the milestones: Backlog, November 2024 Nov 8, 2024
@vs-code-engineering vs-code-engineering bot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Nov 14, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-proposal feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan quick-pick Quick-pick widget issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants