-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Extend Extension API with QuickPickSeparator Support #74967
Comments
Adding an interface similar to the internal one would make sense: interface QuickPickSeparator {
type: 'separator';
label?: string;
} PR welcome. When adding /fyi @jrieken |
Not sure, API via PRs are always hairy because API gets discussed a lot. |
@jrieken @chrmarti I create a draft for the API changes: go2sh@b49406c I'am also almost done with the changes for the extension host components. |
Okay I'am done. I found two things to consider: There are some vscode internal extensions, which use the name type already for a different usage. So it might conflict and thus break some stuff. How do you handle this case? The type of
will break. To avoid this, the type could be Maybe Using a flag for the separator might be less destructive. |
To me, adding a new property to the existing QuickPickItem is an easier way to go Something like export interface QuickPickItem {
...
beginGroup?: boolean;
} or export interface QuickPickItem {
...
beginGroup?: boolean | string;
} If you want to be able to put a label on the separator |
👏 I like that much better @eamodio. Maybe with "begin" but just "group" or "groupInformation" |
We had it as a property on the items in our internal API and it led to complicated code when using it because some otherwise random item suddenly also represents a group of items. That is why I introduced the |
The separator method, seems like it would be problematic with search in the quickpick (or do you just throw away all separators in that case?) @jrieken with this: export interface QuickPickItem {
...
group?: string;
} Would you expect it would still behave as a beginning marker, or an actual grouping construct? While a grouping construct might be nice, it feels like it makes things harder on the QuickPick side if the items in a group aren't consecutive. Although completely out of scope here -- have a true grouping construct, like |
Search rearranges the items according to how well they match, so items are no longer in the original groups. Because of that we remove the separators. (See, e.g., the theme picker.) |
Is this still not implemented? I work on a feature for the CMake extension, which would really benefit of having an item separator to separate the toolchain kits from an action to rescan the system for kits. |
Some comments from my #11468 (closed yesterday as #duplicate in favor of this one), which I think are relevant to be present here Original requestThe idea is to show items in the pick list, just like Go to Symbol, where you have some kind of groups of items (that appears when you type '@:' in the pick list)? More details added 2 days agoI was thinking about a group/category data attached to each But, if the proposed API ( I just wonder how/if I should deal with the ordering, visibility and counting myself when the user filters the PickList, with the I didn't dig in VS Code source to see how the internal API works today, but with the right documentation and samples, I guess it wouldn't be a problem. Thank you |
How about something like this: export interface QuickPick {
...
groups?: QuickPickItemGroup[];
}
export interface QuickPickItemGroup {
id: string;
label?: string;
options?: { showCount?: boolean }; // probably don't need to support this in v1
}
export interface QuickPickItem {
...
group?: string;
} Where you could specify an ordered array of groups, with optional labels, and then apply the group id to each item via the This somewhat follows our menu pattern (with the exception of the defined |
That seems very complicated. Given that a group is just a label, it could be just this
|
Well without specified |
I believe the order is always as it is defined inside the array and when we re-order we don't show groups. For groups without labels - I am not sure that's desirable. |
I like the |
This PR removes the hook in node-debug's auto attach, and uses only js-debug auto attach. As referenced in the linked issues, this involves removing `debug.javascript.usePreviewAutoAttach` and collapsing `debug.node.autoAttach` into `debug.javascript.autoAttachFilter`. The latter option gains a new state: `disabled`. Since there's no runtime cost to having auto attach around, there is now no distinct off versus disabled state. The status bar item and the `Debug: Toggle Auto Attach` command now open a quickpick, which looks like this: ![](https://memes.peet.io/img/20-09-9d2b6c0a-8b3f-4481-b2df-0753c54ee02b.png) The current setting value is selected in the quickpick. If there is a workspace setting for auto attach, the quickpick toggle the setting there by default. Otherwise (as in the image) it will target the user settings. The targeting is more explicit and defaults to the user instead of the workspace, which should help reduce confusion (#97087). Selecting the "scope change" item will reopen the quickpick in that location. Aside from the extra options for the `disabled` state in js-debug's contributions, there's no changes required to it or its interaction with debug-auto-launch. Side note: I really wanted a separator between the states and the scope change item, but this is not possible from an extension #74967. Fixes #105883 Fixes microsoft/vscode-js-debug#732 (the rest of it) Fixes #105963 Fixes #97087
This PR removes the hook in node-debug's auto attach, and uses only js-debug auto attach. As referenced in the linked issues, this involves removing `debug.javascript.usePreviewAutoAttach` and collapsing `debug.node.autoAttach` into `debug.javascript.autoAttachFilter`. The latter option gains a new state: `disabled`. Since there's no runtime cost to having auto attach around, there is now no distinct off versus disabled state. The status bar item and the `Debug: Toggle Auto Attach` command now open a quickpick, which looks like this: ![](https://memes.peet.io/img/20-09-9d2b6c0a-8b3f-4481-b2df-0753c54ee02b.png) The current setting value is selected in the quickpick. If there is a workspace setting for auto attach, the quickpick toggle the setting there by default. Otherwise (as in the image) it will target the user settings. The targeting is more explicit and defaults to the user instead of the workspace, which should help reduce confusion (#97087). Selecting the "scope change" item will reopen the quickpick in that location. Aside from the extra options for the `disabled` state in js-debug's contributions, there's no changes required to it or its interaction with debug-auto-launch. Side note: I really wanted a separator between the states and the scope change item, but this is not possible from an extension #74967. Fixes #105883 Fixes microsoft/vscode-js-debug#732 (the rest of it) Fixes #105963 Fixes #97087
So with the discussion in API sync, I'm proposing: export interface QuickPickItem {
kind?: string | { label: string; };
}
an example: const a = await window.showQuickPick([
{
label: 'asdf',
kind: 'asdf',
},
{
label: 'asdf',
kind: 'asdf'
},
{
label: 'asdf',
kind: 'asdf'
},
{
label: 'asdf',
kind: 'asdf'
},
{
label: 'zxcv',
kind: 'zxcv'
},
{
label: 'zxcv',
kind: 'zxcv'
},
{
label: 'zxcv',
kind: 'zxcv'
},
{
label: 'star',
kind: 'star'
},
{
label: 'idk',
},
]); |
My conclusion is that this is very easy to use for the extension author and I was able to add these separators to existing quick picks with little effort.
I missed this comment before and it brings up a good point... how would we add an arbitrary separator between two groups? If we still encapsulate this in within |
So in standup @connor4312 and @Tyriar convinced me that @connor4312 pointed out that the kind proposal for quickpick separators isn’t ideal because it would not be possible to have a single blank line separating two groups. and @Tyriar pointed out that
we discussed this in the API sync as ‘doc-able’ but I do share the same feeling as he. Further discussion with @jrieken left us with: enum QuickPickItemKind {
Default,
Separator
}
interface QuickPickItem {
// when set to Separator the following properties are ignored....
kind?: QuickPickItemKind
} So that we didn't need a separate type just for separators and so we didn't use string enums or literal or types. However, we can't go down that route because I also wanted to call out that @chrmarti mentioned a tree-like structure... which might have looked similar to what @connor4312 was suggesting here: |
Going down this route... where |
Folks were happy in the API call so let's see how people feel about the API. |
Please take a look at the example in #137745 and don't be afraid to provide feedback here. Moving this to December to track finalization. |
With #21244 QuickPick Controls got the support for separators. This functionality is currently not available through the extensions API. For a nice look and feel, it would be great to make the separators available for extensions.
It seams to be not to hard to implement and I'am willing to do it, but I'am not sure from an API standpoint. Would you accept such a change?
The API could be changed in to ways:
items
to(T | QuickPickSeparator)[]
orReadonlyArray<T | QuickPickSeparator>
The text was updated successfully, but these errors were encountered: