Skip to content

Extend Extension API with QuickPickSeparator Support #74967

Closed

Description

@go2sh

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>

Activity

  1. changed the title [-]Extended Extension API with QuickPick Seperator Support[/-] [+]Extend Extension API with QuickPickSeparator Support[/+] on Jun 6, 2019
  2. added
    feature-request
    quick-pick
    on Jun 6, 2019
  3. chrmarti commented on Jun 6, 2019

    @chrmarti
    Collaborator

    Adding an interface similar to the internal one would make sense:

    interface QuickPickSeparator {
    	type: 'separator';
    	label?: string;
    }

    PR welcome. When adding QuickPickSeparator to the existing API, we will need to make sure we don't break existing clients.

    /fyi Johannes Rieken (@jrieken)

  4. jrieken commented on Jun 6, 2019

    @jrieken
    Contributor

    PR welcome

    Not sure, API via PRs are always hairy because API gets discussed a lot.

  5. go2sh commented on Jun 6, 2019

    @go2sh
    ContributorAuthor

    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.

  6. go2sh commented on Jun 6, 2019

    @go2sh
    ContributorAuthor

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

  7. eamodio commented on Jun 7, 2019

    @eamodio
    Contributor

    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

  8. jrieken commented on Jun 7, 2019

    @jrieken
    Contributor

    👏 I like that much better Eric Amodio (@eamodio). Maybe with "begin" but just "group" or "groupInformation"

  9. chrmarti commented on Jun 7, 2019

    @chrmarti
    Collaborator

    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.

  10. eamodio commented on Jun 7, 2019

    @eamodio
    Contributor

    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:

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

  11. chrmarti commented on Jun 11, 2019

    @chrmarti
    Collaborator

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

  12. 26 remaining items

  13. TylerLeonhardt commented on Nov 12, 2021

    @TylerLeonhardt
    Member

    So in standup Connor Peet (@connor4312) and Daniel Imms (@Tyriar) convinced me that kind is 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 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.

    Further discussion with Johannes Rieken (@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 QuickPickItem#label can'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)

  14. TylerLeonhardt commented on Nov 15, 2021

    @TylerLeonhardt
    Member

    However, we can't go down that route because QuickPickItem#label can't be undefined... where in separators in can...

    Going down this route... where QuickPickItem#label can just be empty string

  15. TylerLeonhardt commented on Nov 16, 2021

    @TylerLeonhardt
    Member

    Folks were happy in the API call so let's see how people feel about the API.

  16. TylerLeonhardt commented on Dec 3, 2021

    @TylerLeonhardt
    Member

    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.

  17. TylerLeonhardt commented on Jan 21, 2022

    @TylerLeonhardt
    Member

    Finalized in e15397d and eb416b4

  18. locked and limited conversation to collaborators on Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api-finalizationfeature-requeston-testplanquick-pick

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions