Vscode: Expand Treeview.reveal function to "not reveal the tree view"

Created on 25 Apr 2020  路  4Comments  路  Source: microsoft/vscode




Today, when you use Treeview.reveal function, no matter the combination you choose for select and focus params, it will always reveal the tree view, if it is not visible.

This is the expected behaviour, based on its documentation

        /**
         * Reveals the given element in the tree view.
         * If the tree view is not visible then the tree view is shown and element is revealed.
         *
         * By default revealed element is selected.
         * In order to not to select, set the option `select` to `false`.
         * In order to focus, set the option `focus` to `true`.
         * In order to expand the revealed element, set the option `expand` to `true`. To expand recursively set `expand` to the number of levels to expand.
         * **NOTE:** You can expand only to 3 levels maximum.
         *
         * **NOTE:** [TreeDataProvider](#TreeDataProvider) is required to implement [getParent](#TreeDataProvider.getParent) method to access this API.
         */
        reveal(element: T, options?: { select?: boolean, focus?: boolean, expand?: boolean | number }): Thenable<void>;

What I'm asking is to have an option to avoid that behaviour, and _simply select_ the desired TreeItem, but leave the tree view hidden. So when the user _intentionally select the tree view_, the previously revealed TreeItem will be _selected/focused_.

I'm basically trying to mimic the Explorer: Auto reveal setting you have natively in VS Code.

Screen Shot 2020-04-25 at 16 03 20

Thank you

explorer-custom feature-request

Most helpful comment

I had a problem with refreshing the tree. I solved my problem with expanding the tree. Then I figured out TreeView is also revealed when the tree expands. I found a solution for the not revealing the tree. This is checking the visibility of the tree. I wrote a sample code below.

let isChanged: boolean = false;

fileWatcher.onDidChange(() => {   
   isChanged = true;
   if (treeView.visible) {   // Reveal if treeview is visible
        reveal(treeItem, {expand: true}); // Reveal
        treeDataProvider.refresh(); // Run your function
        isChanged = false;
   }
});

treeView.onDidChangeVisibility((listener) => { // If visibility changed
    if (listener.visible && isChanged) { // Check visibility and isChanged
        reveal(treeItem, {expand: true}); // Reveal
        treeDataProvider.refresh(); // Run your function
        isChanged = false;
    }
});

All 4 comments


This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

I had a problem with refreshing the tree. I solved my problem with expanding the tree. Then I figured out TreeView is also revealed when the tree expands. I found a solution for the not revealing the tree. This is checking the visibility of the tree. I wrote a sample code below.

let isChanged: boolean = false;

fileWatcher.onDidChange(() => {   
   isChanged = true;
   if (treeView.visible) {   // Reveal if treeview is visible
        reveal(treeItem, {expand: true}); // Reveal
        treeDataProvider.refresh(); // Run your function
        isChanged = false;
   }
});

treeView.onDidChangeVisibility((listener) => { // If visibility changed
    if (listener.visible && isChanged) { // Check visibility and isChanged
        reveal(treeItem, {expand: true}); // Reveal
        treeDataProvider.refresh(); // Run your function
        isChanged = false;
    }
});


This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding


:slightly_frowning_face: In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipgiuliani picture philipgiuliani  路  3Comments

v-pavanp picture v-pavanp  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

sirius1024 picture sirius1024  路  3Comments