提交 950574c3 编写于 作者: S Sandeep Somavarapu

Fix #32012

上级 7fb62434
......@@ -5089,6 +5089,11 @@ declare module 'vscode' {
*/
resourceUri?: Uri;
/**
* The tooltip text when you hover over this item.
*/
tooltip?: string | undefined;
/**
* The [command](#Command) which should be run when the tree item is selected.
*/
......
......@@ -185,6 +185,7 @@ class ExtHostTreeView<T> extends Disposable {
parentHandle,
label: extensionTreeItem.label,
resourceUri: extensionTreeItem.resourceUri,
tooltip: typeof extensionTreeItem.tooltip === 'string' ? extensionTreeItem.tooltip : void 0,
command: extensionTreeItem.command ? this.commands.toInternal(extensionTreeItem.command) : void 0,
contextValue: extensionTreeItem.contextValue,
icon,
......
......@@ -1524,6 +1524,7 @@ export class TreeItem {
iconPath?: string | URI | { light: string | URI; dark: string | URI };
command?: vscode.Command;
contextValue?: string;
tooltip?: string;
constructor(label: string, collapsibleState?: vscode.TreeItemCollapsibleState)
constructor(resourceUri: URI, collapsibleState?: vscode.TreeItemCollapsibleState)
......
......@@ -404,7 +404,7 @@ class TreeRenderer implements IRenderer {
public renderElement(tree: ITree, node: ITreeItem, templateId: string, templateData: ITreeExplorerTemplateData): void {
const resource = node.resourceUri ? URI.revive(node.resourceUri) : null;
const name = node.label ? node.label : resource ? basename(resource.path) : '';
const label = node.label ? node.label : resource ? basename(resource.path) : '';
const icon = this.themeService.getTheme().type === LIGHT ? node.icon : node.iconDark;
// reset
......@@ -415,11 +415,12 @@ class TreeRenderer implements IRenderer {
DOM.removeClass(templateData.resourceLabel.element, 'custom-view-tree-node-item-resourceLabel');
if (resource && !icon) {
templateData.resourceLabel.setLabel({ name, resource }, { fileKind: node.collapsibleState === TreeItemCollapsibleState.Collapsed || node.collapsibleState === TreeItemCollapsibleState.Expanded ? FileKind.FOLDER : FileKind.FILE });
templateData.resourceLabel.setLabel({ name: label, resource }, { fileKind: node.collapsibleState === TreeItemCollapsibleState.Collapsed || node.collapsibleState === TreeItemCollapsibleState.Expanded ? FileKind.FOLDER : FileKind.FILE, title: node.tooltip });
DOM.addClass(templateData.resourceLabel.element, 'custom-view-tree-node-item-resourceLabel');
} else {
templateData.label.textContent = name;
templateData.label.textContent = label;
DOM.addClass(templateData.label, 'custom-view-tree-node-item-label');
templateData.label.title = typeof node.tooltip === 'string' ? node.tooltip : label;
}
templateData.icon.treeItem = node;
......
......@@ -204,6 +204,8 @@ export interface ITreeItem {
parentHandle: string;
collapsibleState: TreeItemCollapsibleState;
label?: string;
icon?: string;
......@@ -212,13 +214,14 @@ export interface ITreeItem {
resourceUri?: UriComponents;
tooltip?: string;
contextValue?: string;
command?: Command;
children?: ITreeItem[];
collapsibleState: TreeItemCollapsibleState;
}
export interface ITreeViewDataProvider {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册