You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extend Extension API with QuickPickSeparator Support #74967
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:
Add a property to the QuickPickItem to show a seperator above, add this seperator in the main thread.
Add a Interface QuickPickSeparator to the extension api and change all occurrences of items to (T | QuickPickSeparator)[] or ReadonlyArray<T | QuickPickSeparator>
Reacted by Eric Amodio, Danny Tuppeny, Hristo Hristov, damolina-stripe, JZ Song, Miguel Solorio, Kaitlin Brooks, Peter van Gulik, Connor Peet, Leo Young and 15 more
changed the title [-]Extended Extension API with QuickPick Seperator Support[/-][+]Extend Extension API with QuickPickSeparator Support[/+]on Jun 6, 2019
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 activeItems and selectedItems is hard. If it's just T code like in the tests:
pick.activeItems = [pick.items[0]];
will break. To avoid this, the type could be T | QuickPickSeperator and the value could be filtered on setting.
Maybe Using a flag for the separator might be less destructive.
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 QuickPickSeparator interface when doing the new implementation.
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 QuickPickGroup that also supported items (and ideally a promise of items), could be a great way of having async groups in the quickpick. For example, in some GitLens quick pick the commands are static, but other parts could be dynamically provided. But I'm getting out of scope for this 😄
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.)
Connor Peet (@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 Daniel Imms (@Tyriar) pointed out that kind is ambiguous if you have a situation like this:
kind: ‘a’
kind: ‘b’
kind: ‘a’
we discussed this in the API sync as ‘doc-able’ but I do share the same feeling as he.
enumQuickPickItemKind{Default,Separator}interfaceQuickPickItem{// when set to Separator the following properties are ignored....kind?: QuickPickItemKind}
Activity
[-]Extended Extension API with QuickPick Seperator Support[/-][+]Extend Extension API with QuickPickSeparator Support[/+]chrmarti commentedon Jun 6, 2019
Adding an interface similar to the internal one would make sense:
PR welcome. When adding
QuickPickSeparatorto the existing API, we will need to make sure we don't break existing clients./fyi Johannes Rieken (@jrieken)
jrieken commentedon Jun 6, 2019
Not sure, API via PRs are always hairy because API gets discussed a lot.
go2sh commentedon Jun 6, 2019
Johannes Rieken (@jrieken) Christof Marti (@chrmarti) I create a draft for the API changes: go2sh@b49406c
Feel free to have a look and discuss it.
I'am also almost done with the changes for the extension host components.
go2sh commentedon Jun 6, 2019
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
activeItemsandselectedItemsis hard. If it's justTcode like in the tests:will break. To avoid this, the type could be
T | QuickPickSeperatorand the value could be filtered on setting.Maybe Using a flag for the separator might be less destructive.
eamodio commentedon Jun 7, 2019
To me, adding a new property to the existing QuickPickItem is an easier way to go
Something like
or
If you want to be able to put a label on the separator
jrieken commentedon Jun 7, 2019
👏 I like that much better Eric Amodio (@eamodio). Maybe with "begin" but just "group" or "groupInformation"
chrmarti commentedon Jun 7, 2019
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
QuickPickSeparatorinterface when doing the new implementation.eamodio commentedon Jun 7, 2019
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?)
Johannes Rieken (@jrieken) with this:
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
QuickPickGroupthat also supported items (and ideally a promise of items), could be a great way of having async groups in the quickpick. For example, in some GitLens quick pick the commands are static, but other parts could be dynamically provided. But I'm getting out of scope for this 😄chrmarti commentedon Jun 11, 2019
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.)
26 remaining items
Revert "First cut of quick pick separators as `kind`. ref #74967"
TylerLeonhardt commentedon Nov 12, 2021
So in standup Connor Peet (@connor4312) and Daniel Imms (@Tyriar) convinced me that
kindis harder to use than a separator...Connor Peet (@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 Daniel Imms (@Tyriar) pointed out that
kindis ambiguous if you have a situation like this:we discussed this in the API sync as ‘doc-able’ but I do share the same feeling as he.
Further discussion with Johannes Rieken (@jrieken) left us with:
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
QuickPickItem#labelcan't be undefined... where in separators in can...I also wanted to call out that Christof Marti (@chrmarti) mentioned a tree-like structure... which might have looked similar to what Connor Peet (@connor4312) was suggesting here:
#74967 (comment)
TylerLeonhardt commentedon Nov 15, 2021
Going down this route... where
QuickPickItem#labelcan just be empty stringTylerLeonhardt commentedon Nov 16, 2021
Folks were happy in the API call so let's see how people feel about the API.
TylerLeonhardt commentedon Dec 3, 2021
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.
TylerLeonhardt commentedon Jan 21, 2022
Finalized in e15397d and eb416b4