From 5665c077c5cd60d1d1a9806e2e729f858e30dbab Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Thu, 16 Aug 2018 12:00:21 -0700 Subject: [PATCH] Fix microsoft/vscode-pull-request-github#168. Use editor font for code in comments. --- .../electron-browser/commentThreadWidget.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts b/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts index d29bdb5fb5d..03253893920 100644 --- a/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts +++ b/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts @@ -117,6 +117,7 @@ export class ReviewZoneWidget extends ZoneWidget { private _commentGlyph: CommentGlyphWidget; private _owner: number; private _localToDispose: IDisposable[]; + private _globalToDispose: IDisposable[]; private _markdownRenderer: MarkdownRenderer; private _styleElement: HTMLStyleElement; private _error: HTMLElement; @@ -145,11 +146,17 @@ export class ReviewZoneWidget extends ZoneWidget { this._owner = owner; this._commentThread = commentThread; this._isCollapsed = commentThread.collapsibleState !== modes.CommentThreadCollapsibleState.Expanded; + this._globalToDispose = []; this._localToDispose = []; this.create(); this._styleElement = dom.createStyleSheet(this.domNode); - this.themeService.onThemeChange(this._applyTheme, this); + this._globalToDispose.push(this.themeService.onThemeChange(this._applyTheme, this)); + this._globalToDispose.push(this.editor.onDidChangeConfiguration(e => { + if (e.fontInfo) { + this._applyTheme(this.themeService.getTheme()); + } + })); this._applyTheme(this.themeService.getTheme()); this._markdownRenderer = new MarkdownRenderer(editor, this.modeService, this.openerService); @@ -627,6 +634,13 @@ export class ReviewZoneWidget extends ZoneWidget { content.push(`.monaco-editor .review-widget .body .comment-form .validation-error { background: ${errorBackground}; }`); } + const fontInfo = this.editor.getConfiguration().fontInfo; + content.push(`.monaco-editor .review-widget .body code { + font-family: ${fontInfo.fontFamily}; + font-size: ${fontInfo.fontSize}px; + font-weight: ${fontInfo.fontWeight}; + }`); + this._styleElement.innerHTML = content.join('\n'); // Editor decorations should also be responsive to theme changes @@ -656,6 +670,7 @@ export class ReviewZoneWidget extends ZoneWidget { this._commentGlyph = null; } + this._globalToDispose.forEach(global => global.dispose()); this._localToDispose.forEach(local => local.dispose()); this._onDidClose.fire(); }