Skip to content

Allow programmatically selecting a TreeItem in custom views #30288

Closed

Description

@Gama11

I've been trying to mimick the files.autoReveal behavior of the regular explorer in the Dependency Explorer of the Haxe extension. I can expand the necessary nodes just fine, but I don't think there's any way to scroll to the correct position in the view + highlight the node programmatically right now.

From what I can tell, the currently planned enhancements won't help with this (#27823). Could a function for selecting a node be added to API? I think a lot of other extensions would benefit from this as well, Code Outline comes to mind.

Activity

  1. added
    tree-views
    feature-request
    on Jul 11, 2017
  2. sailro commented on Oct 21, 2017

    @sailro
    Member

    This is a huge limitation, it would be so great to have such a basic feature when working with custom tree views

  3. pltrant commented on Jan 28, 2018

    @pltrant

    Yes, this API would be very useful for code view/navigation extensions. I have an extension with a custom view and it is frequently requested to highlight the node that represents where they are in the file.

  4. mike-lischke commented on Feb 6, 2018

    @mike-lischke

    This FR could be tracked by #27823. I have (multi) selection per code in my feature wishlist there.

  5. sandy081 commented on Feb 14, 2018

    @sandy081
    Member

    Jens Fischer (@Gama11) Patrick Trant (@pltrant) Can I assume is this request is to have an API to reveal an item in the tree? Or do you also need select as a separate API?

  6. sandy081 commented on Feb 14, 2018

    @sandy081
    Member

    I am working on a proposed API for this which will be available for authors to try out in this iteration and the plan to make it available in main API is in next milestone.

  7. Gama11 commented on Feb 14, 2018

    @Gama11
    ContributorAuthor

    If reveal implies select, that seems good enough to me.

  8. sandy081 commented on Feb 14, 2018

    @sandy081
    Member

    reveal and select are two independent actions.

    reveal - Reveals the item in the tree view.
    select - Selects the item in the tree. Select will not show the item if it is not visible.

  9. Gama11 commented on Feb 14, 2018

    @Gama11
    ContributorAuthor

    In that case, both are needed to mimic the files.autoReveal behavior, as files are also highlighted in the regular file explorer when using that setting.

  10. 24 remaining items

  11. eamodio commented on Mar 1, 2018

    @eamodio
    Contributor

    Sandeep Somavarapu (@sandy081) will this be making the Feb cut? (seems unlikely at this point)

  12. sandy081 commented on Mar 2, 2018

    @sandy081
    Member

    Mike Lischke (@mike-lischke) Sorry for late reply. I was bit busy this week with our release stuff.

    Yes, there are many Tree APIs in the market and they might share some common things and differ in other. We have our own set of protocols to follow before coming up with an API.

    Naming is always tough. We do multiple rounds of feedback and come up with proper name. In this case the extension author wants to reveal a node to the user which makes it obvious to call it reveal. On the other hand expand does not tell about showing to the user.

    properties vs methods and other arguments of yours boils down to the design approach. Our design is pull model that extensions provide to the system, data sources and rendering (like label) providers and system asks for the data and render the view. This is one of the familiar designs for Tree implementation for eg., eclipse JFace Tree view has the similar API: https://www.eclipse.org/articles/Article-TreeViewer/TreeViewerArticle.htm

  13. sandy081 commented on Mar 2, 2018

    @sandy081
    Member

    Eric Amodio (@eamodio) Re gitkraken/vscode-gitlens#275 If I understand correctly, you want the nodes to be auto expanded when view loads them? If so, Is not the collapsibleState property on TreeItem doing it?
    Reveal API is different that it allows you to show a node at any time.

    will this be making the Feb cut? (seems unlikely at this point)?

    It is part of proposed API for Feb release and becomes public for March release.

    Try it out and provide feedback.

  14. eamodio commented on Mar 2, 2018

    @eamodio
    Contributor

    Sandeep Somavarapu (@sandy081) the view will already be loaded and not expanded. I want to be able to have a command to select and expand the item (sometimes 1 level others all descendants).

  15. sandy081 commented on Mar 2, 2018

    @sandy081
    Member

    Eric Amodio (@eamodio) Ah ok. So what is the context when this command is invoked in your case?

  16. eamodio commented on Mar 2, 2018

    @eamodio
    Contributor

    There are multiple scenarios.

    1. A command (from the palette or keyboard shortcut) that just focuses the GitLens/GitLens Results views (so any previous selection would be preserved)
    2. A command (from a quickpick or keyboard shortcut) that would select a branch, and maybe expand it 1 level, or a commit — basically jumping into the GitLens explorer
    3. A command on a node that would expand it and all its children for both the GitLens and GitLens Results views
    4. A command when you execute it on a node in the GitLens explorer, would select and expand a node in the GitLens Results view

    And those are just a few off the top of my head. I want to make jumping into and around the GitLens views more seamless.

  17. sandy081 commented on Mar 19, 2018

    @sandy081
    Member

    Current status: Under discussion about how to expose views in the API - #45994

  18. sandy081 commented on Mar 27, 2018

    @sandy081
    Member

    Verify that you can use the new TreeView.reveal API without having to run the extension in proposed API mode.

  19. locked and limited conversation to collaborators on May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-proposalfeature-requesttree-viewsverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions