Skip to content
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

Add following to TreeView #49970

Merged
merged 3 commits into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5870,6 +5870,21 @@ declare module 'vscode' {
*/
export interface TreeView<T> extends Disposable {

/**
* Event that is fired when an element is expanded
*/
readonly onDidExpandElement: Event<T>;

/**
* Event that is fired when an element is collapsed
*/
readonly onDidCollapseElement: Event<T>;

/**
* Currently selected elements.
*/
readonly selectedElements: ReadonlyArray<T>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just selection is better? That;s what we use in the editor. Also, why is it readonly? How do I selecting something in the tree?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, currently there is no direct API to select. reveal has an option to reveal and select. I am sure there will be select api soon and then I can remove readonly once implemented.


/**
* Reveal an element. By default revealed element is selected.
*
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/api/node/extHostTreeViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape {
}
const treeView = this.createExtHostTreeViewer(viewId, options.treeDataProvider);
return {
get onDidCollapseElement() { return treeView.onDidCollapseElement; },
get onDidExpandElement() { return treeView.onDidExpandElement; },
get selectedElements() { return treeView.selectedElements; },
reveal: (element: T, options?: { select?: boolean }): Thenable<void> => {
return treeView.reveal(element, options);
},
Expand Down