-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Additions to Tree view API #52300
Additions to Tree view API #52300
Changes from 5 commits
76d99c7
bac400f
d0d3915
5538c6e
8af16b5
71659f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6079,6 +6079,30 @@ declare module 'vscode' { | |
|
||
} | ||
|
||
/** | ||
* The event that is fired when there is a change in [tree view's selection](#TreeView.selection) | ||
*/ | ||
export interface TreeViewSelectionChangeEvent<T> { | ||
|
||
/** | ||
* Selected elements. | ||
*/ | ||
selection: T[]; | ||
|
||
} | ||
|
||
/** | ||
* The event that is fired when there is a change in [tree view's visibility](#TreeView.visible) | ||
*/ | ||
export interface TreeViewVisibilityChangeEvent { | ||
|
||
/** | ||
* `true` if the [tree view](#TreeView) is visible otherwise `false`. | ||
*/ | ||
visible: boolean; | ||
|
||
} | ||
|
||
/** | ||
* Represents a Tree view | ||
*/ | ||
|
@@ -6100,16 +6124,33 @@ declare module 'vscode' { | |
readonly selection: ReadonlyArray<T>; | ||
|
||
/** | ||
* Reveal an element. By default revealed element is selected. | ||
* Event that is fired when the [selection](#TreeView.selection) has changed | ||
*/ | ||
readonly onDidChangeSelection: Event<TreeViewSelectionChangeEvent<T>>; | ||
|
||
/** | ||
* `true` if the [tree view](#TreeView) is visible otherwise `false`. | ||
*/ | ||
readonly visible: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only means There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
|
||
/** | ||
* Event that is fired when [visibility](TreeView.visible) has changed | ||
*/ | ||
readonly onDidChangeVisibility: Event<TreeViewVisibilityChangeEvent>; | ||
|
||
/** | ||
* 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 and not focused. | ||
* In order to not to select, set the option `select` to `false`. | ||
* In order to focus, set the option `focus` to `true`. | ||
* | ||
* **NOTE:** [TreeDataProvider](#TreeDataProvider) is required to implement [getParent](#TreeDataProvider.getParent) method to access this API. | ||
*/ | ||
reveal(element: T, options?: { select?: boolean }): Thenable<void>; | ||
reveal(element: T, options?: { select?: boolean, focus?: boolean }): Thenable<void>; | ||
} | ||
|
||
|
||
/** | ||
* A data provider that provides tree data | ||
*/ | ||
|
@@ -6183,10 +6224,15 @@ declare module 'vscode' { | |
tooltip?: string | undefined; | ||
|
||
/** | ||
* The [command](#Command) which should be run when the tree item is selected. | ||
* The [command](#Command) that should run when the user selects the tree item. | ||
*/ | ||
command?: Command; | ||
|
||
/** | ||
* The [command](#Command) that should run when the user double clicks on the tree item. | ||
*/ | ||
doubleClickCommand?: Command; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually don't mention user-gestures like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I am aware that we do not mention user-gestures. But here I did not find a better name. Usage is pretty simple and from its name, this command gets executed when user double clicks on a node. Just to note, even though it is not in API, we talk about single click / double click behaviour in one of our settings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, settings name are the wild-wild-west ;-) What I was asking is why we are adding this and how is this being used? I would find a it rather weird that double vs single clicking an item is different. Since you brought it up, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
One of the use cases is that in a script view, run script on double click and not on single click. Another use case is to pin a document after opening it by double clicking from tree view.
I do not know but looks like it is being respected. But I do not want that behaviour in custom trees. In general, Single click selects or highlights an element and whereas double click executes the function associated to that element. Currently It seems Single clicking is usually a primary action of the mouse we can call double click command as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's something for the UX call I'd say.. Personally, I like when they look and feel alike.
Not sure so about that... Clicking an element in the explorer always opens it, double clicking it also opens it but pins it as well. That reminds me of the alternative menu item which are meant to be a similar but slightly different action. So, maybe call it What would really confuse me as a user would be a tree that doesn't do anything on single click but that does do something on double click. So, maybe we should gear the API towards that not being possible. something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Custom trees cannot inherit generic behaviour because each node behaves differently. For example, if a node has both command and altCommand and user has openMode configured to
I like it 👍 |
||
|
||
/** | ||
* [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add
readonly
and?ReadonlyArray<T>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was there in last milestone. Hope the change will not break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just
readonly
should be enough and non breaking