Support multi-selection of tree items in tree views#12088
Merged
paul-marechal merged 7 commits intoeclipse-theia:masterfrom Jan 25, 2023
Merged
Support multi-selection of tree items in tree views#12088paul-marechal merged 7 commits intoeclipse-theia:masterfrom
paul-marechal merged 7 commits intoeclipse-theia:masterfrom
Conversation
Member
Author
|
Here's the extension: And here's the source: |
Fixes eclipse-theia#9074 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
37cabef to
b96bb28
Compare
I had trouble reading the code keeping track of the kind of node
paul-marechal
approved these changes
Jan 25, 2023
Member
paul-marechal
left a comment
There was a problem hiding this comment.
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}`),
};
}
tsmaeder
commented
Jan 25, 2023
Member
Author
|
@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.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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