diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index fc1ad121e7c29764a96cc3368dae6361141b11ca..ef4c4ed23e6618660b5e452c5071ec32f426b461 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLine.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts @@ -9,7 +9,7 @@ import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import { IConfiguration } from 'vs/editor/common/editorCommon'; -import { Decoration } from 'vs/editor/common/viewLayout/viewLineParts'; +import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations'; import { renderViewLine, RenderLineInput, CharacterMapping } from 'vs/editor/common/viewLayout/viewLineRenderer'; import { ClassNames } from 'vs/editor/browser/editorBrowser'; import { IVisibleLine } from 'vs/editor/browser/view/viewLayer'; @@ -149,7 +149,7 @@ export class ViewLine implements IVisibleLine { const lineData = viewportData.getViewLineRenderingData(lineNumber); const options = this._options; - const actualInlineDecorations = Decoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn); + const actualInlineDecorations = LineDecoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn); let renderLineInput = new RenderLineInput( options.useMonospaceOptimizations, lineData.content, diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index 56fdbf5ee07458df1d66cc994c08dae949bbd931..ed727bb7bcf527bfe61c4f0a0f7b98f448ecaf13 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -19,7 +19,7 @@ import { DefaultConfig } from 'vs/editor/common/config/defaultConfig'; import { Range } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; -import { Decoration } from 'vs/editor/common/viewLayout/viewLineParts'; +import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations'; import { renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer'; import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { CodeEditor } from 'vs/editor/browser/codeEditor'; @@ -1903,7 +1903,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { private renderOriginalLine(count: number, originalModel: editorCommon.IModel, config: editorCommon.InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[]): string[] { let lineContent = originalModel.getLineContent(lineNumber); - let actualDecorations = Decoration.filter(decorations, lineNumber, 1, lineContent.length + 1); + let actualDecorations = LineDecoration.filter(decorations, lineNumber, 1, lineContent.length + 1); const defaultMetadata = ( (FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET) diff --git a/src/vs/editor/common/viewLayout/viewLineParts.ts b/src/vs/editor/common/viewLayout/lineDecorations.ts similarity index 88% rename from src/vs/editor/common/viewLayout/viewLineParts.ts rename to src/vs/editor/common/viewLayout/lineDecorations.ts index fbfd54e6f895dcac1b7b6781b31624db7be48b88..23e06adf2cdf471cb538f97a0314f485f68afe74 100644 --- a/src/vs/editor/common/viewLayout/viewLineParts.ts +++ b/src/vs/editor/common/viewLayout/lineDecorations.ts @@ -7,8 +7,8 @@ import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel'; import { Constants } from 'vs/editor/common/core/uint'; -export class Decoration { - _decorationBrand: void; +export class LineDecoration { + _lineDecorationBrand: void; public readonly startColumn: number; public readonly endColumn: number; @@ -22,7 +22,7 @@ export class Decoration { this.insertsBeforeOrAfter = insertsBeforeOrAfter; } - private static _equals(a: Decoration, b: Decoration): boolean { + private static _equals(a: LineDecoration, b: LineDecoration): boolean { return ( a.startColumn === b.startColumn && a.endColumn === b.endColumn @@ -31,26 +31,26 @@ export class Decoration { ); } - public static equalsArr(a: Decoration[], b: Decoration[]): boolean { + public static equalsArr(a: LineDecoration[], b: LineDecoration[]): boolean { let aLen = a.length; let bLen = b.length; if (aLen !== bLen) { return false; } for (let i = 0; i < aLen; i++) { - if (!Decoration._equals(a[i], b[i])) { + if (!LineDecoration._equals(a[i], b[i])) { return false; } } return true; } - public static filter(lineDecorations: InlineDecoration[], lineNumber: number, minLineColumn: number, maxLineColumn: number): Decoration[] { + public static filter(lineDecorations: InlineDecoration[], lineNumber: number, minLineColumn: number, maxLineColumn: number): LineDecoration[] { if (lineDecorations.length === 0) { return []; } - let result: Decoration[] = [], resultLen = 0; + let result: LineDecoration[] = [], resultLen = 0; for (let i = 0, len = lineDecorations.length; i < len; i++) { let d = lineDecorations[i]; @@ -74,13 +74,13 @@ export class Decoration { continue; } - result[resultLen++] = new Decoration(startColumn, endColumn, d.inlineClassName, d.insertsBeforeOrAfter); + result[resultLen++] = new LineDecoration(startColumn, endColumn, d.inlineClassName, d.insertsBeforeOrAfter); } return result; } - public static compare(a: Decoration, b: Decoration): number { + public static compare(a: LineDecoration, b: LineDecoration): number { if (a.startColumn === b.startColumn) { if (a.endColumn === b.endColumn) { if (a.className < b.className) { @@ -172,7 +172,7 @@ export class LineDecorationsNormalizer { /** * Normalize line decorations. Overlapping decorations will generate multiple segments */ - public static normalize(lineDecorations: Decoration[]): DecorationSegment[] { + public static normalize(lineDecorations: LineDecoration[]): DecorationSegment[] { if (lineDecorations.length === 0) { return []; } diff --git a/src/vs/editor/common/viewLayout/viewLineRenderer.ts b/src/vs/editor/common/viewLayout/viewLineRenderer.ts index 6d2040693dd2e128ef7ee34c6d666de90406f3b0..aee872058b313455ae68d74f07dc7fc1d483e23b 100644 --- a/src/vs/editor/common/viewLayout/viewLineRenderer.ts +++ b/src/vs/editor/common/viewLayout/viewLineRenderer.ts @@ -6,7 +6,7 @@ import { ViewLineToken } from 'vs/editor/common/core/viewLineToken'; import { CharCode } from 'vs/base/common/charCode'; -import { Decoration, LineDecorationsNormalizer } from 'vs/editor/common/viewLayout/viewLineParts'; +import { LineDecoration, LineDecorationsNormalizer } from 'vs/editor/common/viewLayout/lineDecorations'; import * as strings from 'vs/base/common/strings'; export const enum RenderWhitespace { @@ -37,7 +37,7 @@ export class RenderLineInput { public readonly mightContainRTL: boolean; public readonly fauxIndentLength: number; public readonly lineTokens: ViewLineToken[]; - public readonly lineDecorations: Decoration[]; + public readonly lineDecorations: LineDecoration[]; public readonly tabSize: number; public readonly spaceWidth: number; public readonly stopRenderingLineAfter: number; @@ -50,7 +50,7 @@ export class RenderLineInput { mightContainRTL: boolean, fauxIndentLength: number, lineTokens: ViewLineToken[], - lineDecorations: Decoration[], + lineDecorations: LineDecoration[], tabSize: number, spaceWidth: number, stopRenderingLineAfter: number, @@ -87,7 +87,7 @@ export class RenderLineInput { && this.stopRenderingLineAfter === other.stopRenderingLineAfter && this.renderWhitespace === other.renderWhitespace && this.renderControlCharacters === other.renderControlCharacters - && Decoration.equalsArr(this.lineDecorations, other.lineDecorations) + && LineDecoration.equalsArr(this.lineDecorations, other.lineDecorations) && ViewLineToken.equalsArr(this.lineTokens, other.lineTokens) ); } @@ -493,8 +493,8 @@ function _applyRenderWhitespace(lineContent: string, len: number, tokens: LinePa * Inline decorations are "merged" on top of tokens. * Special care must be taken when multiple inline decorations are at play and they overlap. */ -function _applyInlineDecorations(lineContent: string, len: number, tokens: LinePart[], _lineDecorations: Decoration[]): LinePart[] { - _lineDecorations.sort(Decoration.compare); +function _applyInlineDecorations(lineContent: string, len: number, tokens: LinePart[], _lineDecorations: LineDecoration[]): LinePart[] { + _lineDecorations.sort(LineDecoration.compare); const lineDecorations = LineDecorationsNormalizer.normalize(_lineDecorations); const lineDecorationsLen = lineDecorations.length; diff --git a/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts b/src/vs/editor/test/common/viewLayout/lineDecorations.test.ts similarity index 67% rename from src/vs/editor/test/common/viewLayout/viewLineParts.test.ts rename to src/vs/editor/test/common/viewLayout/lineDecorations.test.ts index 9c4434c3da2bf38200e4a4cf915d7fc893328f11..97397be1310bec851c98a9e5a0ac2bb834a823ba 100644 --- a/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts +++ b/src/vs/editor/test/common/viewLayout/lineDecorations.test.ts @@ -5,7 +5,7 @@ 'use strict'; import * as assert from 'assert'; -import { DecorationSegment, LineDecorationsNormalizer, Decoration } from 'vs/editor/common/viewLayout/viewLineParts'; +import { DecorationSegment, LineDecorationsNormalizer, LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations'; import { Range } from 'vs/editor/common/core/range'; import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel'; @@ -18,8 +18,8 @@ suite('Editor ViewLayout - ViewLineParts', () => { test('Bug 9827:Overlapping inline decorations can cause wrong inline class to be applied', () => { var result = LineDecorationsNormalizer.normalize([ - new Decoration(1, 11, 'c1', false), - new Decoration(3, 4, 'c2', false) + new LineDecoration(1, 11, 'c1', false), + new LineDecoration(3, 4, 'c2', false) ]); assert.deepEqual(result, [ @@ -32,8 +32,8 @@ suite('Editor ViewLayout - ViewLineParts', () => { test('issue #3462: no whitespace shown at the end of a decorated line', () => { var result = LineDecorationsNormalizer.normalize([ - new Decoration(15, 21, 'vs-whitespace', false), - new Decoration(20, 21, 'inline-folded', false), + new LineDecoration(15, 21, 'vs-whitespace', false), + new LineDecoration(20, 21, 'inline-folded', false), ]); assert.deepEqual(result, [ @@ -44,77 +44,77 @@ suite('Editor ViewLayout - ViewLineParts', () => { test('issue #3661: Link decoration bleeds to next line when wrapping', () => { - let result = Decoration.filter([ + let result = LineDecoration.filter([ newDecoration(2, 12, 3, 30, 'detected-link') ], 3, 12, 500); assert.deepEqual(result, [ - new Decoration(12, 30, 'detected-link', false), + new LineDecoration(12, 30, 'detected-link', false), ]); }); test('ViewLineParts', () => { assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 2, 'c1', false), - new Decoration(3, 4, 'c2', false) + new LineDecoration(1, 2, 'c1', false), + new LineDecoration(3, 4, 'c2', false) ]), [ new DecorationSegment(0, 0, 'c1'), new DecorationSegment(2, 2, 'c2') ]); assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 3, 'c1', false), - new Decoration(3, 4, 'c2', false) + new LineDecoration(1, 3, 'c1', false), + new LineDecoration(3, 4, 'c2', false) ]), [ new DecorationSegment(0, 1, 'c1'), new DecorationSegment(2, 2, 'c2') ]); assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 4, 'c1', false), - new Decoration(3, 4, 'c2', false) + new LineDecoration(1, 4, 'c1', false), + new LineDecoration(3, 4, 'c2', false) ]), [ new DecorationSegment(0, 1, 'c1'), new DecorationSegment(2, 2, 'c1 c2') ]); assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 4, 'c1', false), - new Decoration(1, 4, 'c1*', false), - new Decoration(3, 4, 'c2', false) + new LineDecoration(1, 4, 'c1', false), + new LineDecoration(1, 4, 'c1*', false), + new LineDecoration(3, 4, 'c2', false) ]), [ new DecorationSegment(0, 1, 'c1 c1*'), new DecorationSegment(2, 2, 'c1 c1* c2') ]); assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 4, 'c1', false), - new Decoration(1, 4, 'c1*', false), - new Decoration(1, 4, 'c1**', false), - new Decoration(3, 4, 'c2', false) + new LineDecoration(1, 4, 'c1', false), + new LineDecoration(1, 4, 'c1*', false), + new LineDecoration(1, 4, 'c1**', false), + new LineDecoration(3, 4, 'c2', false) ]), [ new DecorationSegment(0, 1, 'c1 c1* c1**'), new DecorationSegment(2, 2, 'c1 c1* c1** c2') ]); assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 4, 'c1', false), - new Decoration(1, 4, 'c1*', false), - new Decoration(1, 4, 'c1**', false), - new Decoration(3, 4, 'c2', false), - new Decoration(3, 4, 'c2*', false) + new LineDecoration(1, 4, 'c1', false), + new LineDecoration(1, 4, 'c1*', false), + new LineDecoration(1, 4, 'c1**', false), + new LineDecoration(3, 4, 'c2', false), + new LineDecoration(3, 4, 'c2*', false) ]), [ new DecorationSegment(0, 1, 'c1 c1* c1**'), new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*') ]); assert.deepEqual(LineDecorationsNormalizer.normalize([ - new Decoration(1, 4, 'c1', false), - new Decoration(1, 4, 'c1*', false), - new Decoration(1, 4, 'c1**', false), - new Decoration(3, 4, 'c2', false), - new Decoration(3, 5, 'c2*', false) + new LineDecoration(1, 4, 'c1', false), + new LineDecoration(1, 4, 'c1*', false), + new LineDecoration(1, 4, 'c1**', false), + new LineDecoration(3, 4, 'c2', false), + new LineDecoration(3, 5, 'c2*', false) ]), [ new DecorationSegment(0, 1, 'c1 c1* c1**'), new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*'), diff --git a/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts b/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts index 0f8ec6594615799e467d14358341ae8d5c610c29..ad4532369772184fdd10372e113a884fa45c1aa4 100644 --- a/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts +++ b/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts @@ -9,7 +9,7 @@ import { renderViewLine, RenderLineInput, CharacterMapping } from 'vs/editor/com import { ViewLineToken } from 'vs/editor/common/core/viewLineToken'; import { CharCode } from 'vs/base/common/charCode'; import { MetadataConsts } from 'vs/editor/common/modes'; -import { Decoration } from 'vs/editor/common/viewLayout/viewLineParts'; +import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations'; suite('viewLineRenderer.renderLine', () => { @@ -639,7 +639,7 @@ suite('viewLineRenderer.renderLine 2', () => { false, 0, [createPart(21, 3)], - [new Decoration(1, 22, 'link', false)], + [new LineDecoration(1, 22, 'link', false)], 4, 10, -1, @@ -673,7 +673,7 @@ suite('viewLineRenderer.renderLine 2', () => { createPart(84, 6), ], [ - new Decoration(13, 51, 'detected-link', false) + new LineDecoration(13, 51, 'detected-link', false) ], 4, 10, @@ -930,9 +930,9 @@ suite('viewLineRenderer.renderLine 2', () => { 0, [createPart(11, 0)], [ - new Decoration(5, 7, 'a', false), - new Decoration(1, 3, 'b', false), - new Decoration(2, 8, 'c', false), + new LineDecoration(5, 7, 'a', false), + new LineDecoration(1, 3, 'b', false), + new LineDecoration(2, 8, 'c', false), ], 4, 10,