Skip to content

Commit

Permalink
Render inline text selection if the theme is hc-black
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jun 23, 2017
1 parent 9fdc37f commit 779a7df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/vs/editor/browser/viewParts/lines/viewLine.ts
Expand Up @@ -15,6 +15,7 @@ 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 { ThemeType, HIGH_CONTRAST } from "vs/platform/theme/common/themeService";

const canUseFastRenderedViewLine = (function () {
if (platform.isNative) {
Expand All @@ -40,7 +41,7 @@ const canUseFastRenderedViewLine = (function () {
return true;
})();

const renderInlineSelection = (browser.isEdgeOrIE);
const alwaysRenderInlineSelection = (browser.isEdgeOrIE);

export class DomReadingContext {

Expand All @@ -67,6 +68,7 @@ export class DomReadingContext {
}

export class ViewLineOptions {
public readonly themeType: ThemeType;
public readonly renderWhitespace: 'none' | 'boundary' | 'all';
public readonly renderControlCharacters: boolean;
public readonly spaceWidth: number;
Expand All @@ -75,7 +77,8 @@ export class ViewLineOptions {
public readonly stopRenderingLineAfter: number;
public readonly fontLigatures: boolean;

constructor(config: IConfiguration) {
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;
Expand All @@ -90,7 +93,8 @@ export class ViewLineOptions {

public equals(other: ViewLineOptions): boolean {
return (
this.renderWhitespace === other.renderWhitespace
this.themeType === other.themeType
&& this.renderWhitespace === other.renderWhitespace
&& this.renderControlCharacters === other.renderControlCharacters
&& this.spaceWidth === other.spaceWidth
&& this.useMonospaceOptimizations === other.useMonospaceOptimizations
Expand Down Expand Up @@ -145,7 +149,7 @@ export class ViewLine implements IVisibleLine {
this._options = newOptions;
}
public onSelectionChanged(): boolean {
if (renderInlineSelection) {
if (alwaysRenderInlineSelection) {
this._isMaybeInvalid = true;
return true;
}
Expand All @@ -164,7 +168,7 @@ export class ViewLine implements IVisibleLine {
const options = this._options;
const actualInlineDecorations = LineDecoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn);

if (renderInlineSelection) {
if (alwaysRenderInlineSelection || options.themeType === HIGH_CONTRAST) {
const selections = viewportData.selections;
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
Expand Down
25 changes: 18 additions & 7 deletions src/vs/editor/browser/viewParts/lines/viewLines.ts
Expand Up @@ -76,7 +76,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
this._isViewportWrapping = conf.editor.wrappingInfo.isViewportWrapping;
this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding;
this._canUseLayerHinting = conf.editor.canUseLayerHinting;
this._viewLineOptions = new ViewLineOptions(conf);
this._viewLineOptions = new ViewLineOptions(conf, this._context.theme.type);

PartFingerprints.write(this.domNode, PartFingerprint.ViewLines);
this.domNode.setClassName('view-lines');
Expand Down Expand Up @@ -139,7 +139,18 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo);
}

let newViewLineOptions = new ViewLineOptions(conf);
this._onOptionsMaybeChanged();

if (e.layoutInfo) {
this._maxLineWidth = 0;
}

return true;
}
private _onOptionsMaybeChanged(): boolean {
const conf = this._context.configuration;

let newViewLineOptions = new ViewLineOptions(conf, this._context.theme.type);
if (!this._viewLineOptions.equals(newViewLineOptions)) {
this._viewLineOptions = newViewLineOptions;

Expand All @@ -149,13 +160,10 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
let line = this._visibleLines.getVisibleLine(lineNumber);
line.onOptionsChanged(this._viewLineOptions);
}
return true;
}

if (e.layoutInfo) {
this._maxLineWidth = 0;
}

return true;
return false;
}
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
let rendStartLineNumber = this._visibleLines.getStartLineNumber();
Expand Down Expand Up @@ -214,6 +222,9 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
public onZonesChanged(e: viewEvents.ViewZonesChangedEvent): boolean {
return this._visibleLines.onZonesChanged(e);
}
public onThemeChanged(e: viewEvents.ViewThemeChangedEvent): boolean {
return this._onOptionsMaybeChanged();
}

// ---- end view event handlers

Expand Down

0 comments on commit 779a7df

Please sign in to comment.