From 9adc5213a298ebf89fd7196a892dec7647fcc627 Mon Sep 17 00:00:00 2001 From: shuyaqian <717749594@qq.com> Date: Tue, 12 Oct 2021 15:47:55 +0800 Subject: [PATCH] fix descriptions missing in tree Signed-off-by: shuyaqian 717749594@qq.com --- CHANGELOG.md | 1 + .../main/browser/view/tree-view-widget.tsx | 38 ++----------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aabfc5d2a5004..e424c088ea248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - renamed `handleDefault` to `handleElectronDefault` - renamed `createContextMenu` to `createElectronContextMenu` - renamed `createMenuBar` to `createElectronMenuBar` +- [plugin-ext] removed unnecessary function `getCaption` [#10253](https://github.com/eclipse-theia/theia/pull/10253) - [core] moved `DEFAULT_WINDOW_HASH` to `common/window.ts` [#10291](https://github.com/eclipse-theia/theia/pull/10291) - [core] moved `NewWindowOptions` to `common/window.ts` [#10291](https://github.com/eclipse-theia/theia/pull/10291) diff --git a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx index fd034ef4ce807..ebf297df62718 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx +++ b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx @@ -319,43 +319,11 @@ export class TreeViewWidget extends TreeViewWelcomeWidget { } else if (!highlight) { children.push(caption); } - return React.createElement('div', attrs, ...children); - } - - protected getCaption(node: TreeNode): React.ReactNode { - const nodes: React.ReactNode[] = []; - - const name = this.toNodeName(node) || ''; const description = this.toNodeDescription(node); - - let work = name; - - const regex = /\[([^\[]+)\]\(([^\)]+)\)/g; - const matchResult = work.match(regex); - - if (matchResult) { - matchResult.forEach((match, index) => { - nodes.push({work.substring(0, work.indexOf(match))}); - - const execResult = regex.exec(name); - nodes.push( e.stopPropagation()}>{execResult![1]} - ); - - work = work.substring(work.indexOf(match) + match.length); - }); + if (description) { + children.push({description}); } - - return
- {...nodes} - {work && {work}} - {description && - {description} - } -
; + return React.createElement('div', attrs, ...children); } protected renderTailDecorations(node: TreeViewNode, props: NodeProps): React.ReactNode {