diff --git a/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts b/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts index 837b56fc23897dd484496f873e4f6763061f121f..c916bec1da87796c92178fa7b9c8c872358eeab0 100644 --- a/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts +++ b/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts @@ -23,6 +23,7 @@ import { ICommentService, IWorkspaceCommentThreadsEvent } from 'vs/workbench/par import { IEditorService, ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { textLinkForeground, textLinkActiveForeground, focusBorder } from 'vs/platform/theme/common/colorRegistry'; +import { IOpenerService } from 'vs/platform/opener/common/opener'; export const COMMENTS_PANEL_ID = 'workbench.panel.comments'; export const COMMENTS_PANEL_TITLE = 'Comments'; @@ -40,6 +41,7 @@ export class CommentsPanel extends Panel { @ICommentService private commentService: ICommentService, @IEditorService private editorService: IEditorService, @ICommandService private commandService: ICommandService, + @IOpenerService private openerService: IOpenerService, @ITelemetryService telemetryService: ITelemetryService, @IThemeService themeService: IThemeService ) { @@ -130,7 +132,7 @@ export class CommentsPanel extends Panel { private createTree(): void { this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, { dataSource: new CommentsDataSource(), - renderer: new CommentsModelRenderer(this.instantiationService), + renderer: new CommentsModelRenderer(this.instantiationService, this.openerService), accessibilityProvider: new DefaultAccessibilityProvider, controller: new DefaultController(), dnd: new DefaultDragAndDrop(), diff --git a/src/vs/workbench/parts/comments/electron-browser/commentsTreeViewer.ts b/src/vs/workbench/parts/comments/electron-browser/commentsTreeViewer.ts index df16d6514253f026c509b41d88442b30a842f429..d8672d23d57ada9a84a1ce2e3047b656926249e1 100644 --- a/src/vs/workbench/parts/comments/electron-browser/commentsTreeViewer.ts +++ b/src/vs/workbench/parts/comments/electron-browser/commentsTreeViewer.ts @@ -5,9 +5,13 @@ import * as dom from 'vs/base/browser/dom'; import { renderMarkdown } from 'vs/base/browser/htmlContentRenderer'; +import { onUnexpectedError } from 'vs/base/common/errors'; +import { Disposable } from 'vs/base/common/lifecycle'; +import URI from 'vs/base/common/uri'; import { Promise, TPromise } from 'vs/base/common/winjs.base'; import { IDataSource, IFilter, IRenderer as ITreeRenderer, ITree } from 'vs/base/parts/tree/browser/tree'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IOpenerService } from 'vs/platform/opener/common/opener'; import { FileLabel } from 'vs/workbench/browser/labels'; import { CommentNode, CommentsModel, ResourceWithCommentThreads } from 'vs/workbench/parts/comments/common/commentModel'; @@ -59,6 +63,7 @@ interface ICommentThreadTemplateData { icon: HTMLImageElement; userName: HTMLSpanElement; commentText: HTMLElement; + disposables: Disposable[]; } export class CommentsModelRenderer implements ITreeRenderer { @@ -67,7 +72,8 @@ export class CommentsModelRenderer implements ITreeRenderer { constructor( - @IInstantiationService private instantiationService: IInstantiationService + @IInstantiationService private instantiationService: IInstantiationService, + @IOpenerService private openerService: IOpenerService ) { } @@ -99,6 +105,10 @@ export class CommentsModelRenderer implements ITreeRenderer { switch (templateId) { case CommentsModelRenderer.RESOURCE_ID: (templateData).resourceLabel.dispose(); + break; + case CommentsModelRenderer.COMMENT_ID: + (templateData).disposables.forEach(disposeable => disposeable.dispose()); + break; } } @@ -124,6 +134,7 @@ export class CommentsModelRenderer implements ITreeRenderer { const labelContainer = dom.append(container, dom.$('.comment-container')); data.userName = dom.append(labelContainer, dom.$('.user')); data.commentText = dom.append(labelContainer, dom.$('.text')); + data.disposables = []; return data; } @@ -134,7 +145,18 @@ export class CommentsModelRenderer implements ITreeRenderer { private renderCommentElement(tree: ITree, element: CommentNode, templateData: ICommentThreadTemplateData) { templateData.userName.textContent = element.comment.userName; - templateData.commentText.innerHTML = renderMarkdown(element.comment.body, { inline: true }).innerHTML; + templateData.commentText.innerHTML = ''; + const renderedComment = renderMarkdown(element.comment.body, { + inline: true, + actionHandler: { + callback: (content) => { + this.openerService.open(URI.parse(content)).then(void 0, onUnexpectedError); + }, + disposeables: templateData.disposables + } + }); + + templateData.commentText.appendChild(renderedComment); } }