From ef63dd8b3bd5f4e1bdf50d6db0761e67853954c2 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 23 Oct 2017 17:14:39 +0200 Subject: [PATCH] Revert "[theming] editor.selectionForeground is not working. Fixes #36490" This reverts commit 3a3f0e41968ddd3cef6c1e4a090ca8ef8bc6b049. See #36760 --- src/vs/editor/browser/viewParts/lines/viewLine.ts | 15 +++++++-------- .../editor/browser/viewParts/lines/viewLines.ts | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index 37625d0dbaf6..8c5c4ff20e36 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLine.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts @@ -15,9 +15,8 @@ import { IVisibleLine } from 'vs/editor/browser/view/viewLayer'; import { RangeUtil } from 'vs/editor/browser/viewParts/lines/rangeUtil'; import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; -import { ITheme } from 'vs/platform/theme/common/themeService'; +import { ThemeType, HIGH_CONTRAST } from 'vs/platform/theme/common/themeService'; import { IStringBuilder } from 'vs/editor/common/core/stringBuilder'; -import { editorSelectionForeground } from 'vs/platform/theme/common/colorRegistry'; const canUseFastRenderedViewLine = (function () { if (platform.isNative) { @@ -70,7 +69,7 @@ export class DomReadingContext { } export class ViewLineOptions { - public readonly useSelectionForegroundColor: boolean; + public readonly themeType: ThemeType; public readonly renderWhitespace: 'none' | 'boundary' | 'all'; public readonly renderControlCharacters: boolean; public readonly spaceWidth: number; @@ -79,8 +78,8 @@ export class ViewLineOptions { public readonly stopRenderingLineAfter: number; public readonly fontLigatures: boolean; - constructor(config: IConfiguration, theme: ITheme) { - this.useSelectionForegroundColor = !!theme.getColor(editorSelectionForeground); + constructor(config: IConfiguration, themeType: ThemeType) { + this.themeType = themeType; this.renderWhitespace = config.editor.viewInfo.renderWhitespace; this.renderControlCharacters = config.editor.viewInfo.renderControlCharacters; this.spaceWidth = config.editor.fontInfo.spaceWidth; @@ -95,7 +94,7 @@ export class ViewLineOptions { public equals(other: ViewLineOptions): boolean { return ( - this.useSelectionForegroundColor === other.useSelectionForegroundColor + this.themeType === other.themeType && this.renderWhitespace === other.renderWhitespace && this.renderControlCharacters === other.renderControlCharacters && this.spaceWidth === other.spaceWidth @@ -151,7 +150,7 @@ export class ViewLine implements IVisibleLine { this._options = newOptions; } public onSelectionChanged(): boolean { - if (alwaysRenderInlineSelection || this._options.useSelectionForegroundColor) { + if (alwaysRenderInlineSelection || this._options.themeType === HIGH_CONTRAST) { this._isMaybeInvalid = true; return true; } @@ -170,7 +169,7 @@ export class ViewLine implements IVisibleLine { const options = this._options; const actualInlineDecorations = LineDecoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn); - if (alwaysRenderInlineSelection || options.useSelectionForegroundColor) { + if (alwaysRenderInlineSelection || options.themeType === HIGH_CONTRAST) { const selections = viewportData.selections; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 9c873fa94963..14341b3c9526 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -96,7 +96,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._isViewportWrapping = conf.editor.wrappingInfo.isViewportWrapping; this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding; this._canUseLayerHinting = conf.editor.canUseLayerHinting; - this._viewLineOptions = new ViewLineOptions(conf, this._context.theme); + this._viewLineOptions = new ViewLineOptions(conf, this._context.theme.type); PartFingerprints.write(this.domNode, PartFingerprint.ViewLines); this.domNode.setClassName('view-lines'); @@ -170,7 +170,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, private _onOptionsMaybeChanged(): boolean { const conf = this._context.configuration; - let newViewLineOptions = new ViewLineOptions(conf, this._context.theme); + let newViewLineOptions = new ViewLineOptions(conf, this._context.theme.type); if (!this._viewLineOptions.equals(newViewLineOptions)) { this._viewLineOptions = newViewLineOptions;