-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support multi-selection of tree items in tree views #12088
Support multi-selection of tree items in tree views #12088
Conversation
Here's the extension: And here's the source: |
Fixes eclipse-theia#9074 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <[email protected]>
37cabef
to
b96bb28
Compare
I had trouble reading the code keeping track of the kind of node
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.
The changes work as described when using the provided extension, although I made some modifications to make sure that inline actions also work properly:
I added the following menu entry in the extension's package.json
:
{
"command": "treeViewDnD.printSelection",
"when": "view == testViewDragAndDrop && viewItem == aaaaaa",
"group": "inline"
}
Along with editing the following code:
// file: out/testViewDragAndDrop.js
// class: TestViewDragAndDrop
_getTreeItem(key) {
const treeElement = this._getTreeElement(key);
// An example of how to use codicons in a MarkdownString in a tree item tooltip.
const tooltip = new vscode.MarkdownString(`$(zap) Tooltip for ${key}`, true);
return {
// required for `viewItem == X` to work:
contextValue: key,
label: /**vscode.TreeItemLabel**/ { label: key, highlights: key.length > 1 ? [[key.length - 2, key.length - 1]] : void 0 },
tooltip,
collapsibleState: treeElement && Object.keys(treeElement).length ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None,
resourceUri: vscode.Uri.parse(`/tmp/${key}`),
};
}
@paul-marechal since you changed some code and I assume you tested it, I'll let you merge the changes. |
Use an option object instead of several optional positional arguments. This makes some lines shorter, enough to make ESLint happy.
What it does
Adds multi-selection support to tree views contributed via VS Code API
Fixes #9074
Contributed on behalf of STMicroelectronics
How to test
The attached extension contributes a tree view that has multi-select enabled. There is a command "Print Selection" which prints out the selected items on the extension side. Make sure the behavior is consistent with VS Code.
Review checklist
Reminder for reviewers