diff --git a/src/vs/editor/browser/standalone/colorizer.ts b/src/vs/editor/browser/standalone/colorizer.ts
index 09c1537c32a1279f27cea487be7c853285488ecf..cc370e16139ea7040f686d34478501c9f12dd0e2 100644
--- a/src/vs/editor/browser/standalone/colorizer.ts
+++ b/src/vs/editor/browser/standalone/colorizer.ts
@@ -10,7 +10,7 @@ import { IModel } from 'vs/editor/common/editorCommon';
import { TokenizationRegistry, ITokenizationSupport } from 'vs/editor/common/modes';
import { IModeService } from 'vs/editor/common/services/modeService';
import { renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
-import { ViewLineToken, ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { LineTokens } from 'vs/editor/common/core/lineTokens';
import * as strings from 'vs/base/common/strings';
import { IStandaloneColorService } from 'vs/editor/common/services/standaloneColorService';
@@ -97,7 +97,8 @@ export class Colorizer {
public static colorizeLine(line: string, tokens: ViewLineToken[], tabSize: number = 4): string {
let renderResult = renderViewLine(new RenderLineInput(
line,
- new ViewLineTokens(tokens, 0, line.length),
+ 0,
+ tokens,
[],
tabSize,
0,
@@ -128,7 +129,8 @@ function _fakeColorize(lines: string[], tabSize: number): string {
let renderResult = renderViewLine(new RenderLineInput(
line,
- new ViewLineTokens([], 0, line.length),
+ 0,
+ [new ViewLineToken(line.length, '')],
[],
tabSize,
0,
@@ -155,7 +157,8 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport:
let lineTokens = new LineTokens(colorMap, tokenizeResult.tokens, line);
let renderResult = renderViewLine(new RenderLineInput(
line,
- new ViewLineTokens(lineTokens.inflate(), 0, line.length),
+ 0,
+ lineTokens.inflate(),
[],
tabSize,
0,
diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts
index b0dae8ab008aab77ad839701ad83c437fad03daf..14bebc00d2a1b82b10e04e19dde8509d6adff239 100644
--- a/src/vs/editor/browser/viewParts/lines/viewLine.ts
+++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts
@@ -102,6 +102,7 @@ export class ViewLine implements IVisibleLineData {
let renderLineInput = new RenderLineInput(
model.getLineContent(lineNumber),
+ model.getLineMinColumn(lineNumber) - 1,
model.getLineTokens(lineNumber),
actualInlineDecorations,
model.getTabSize(),
diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts
index 251816f0b74bce3a0c698757b3079ebb34dc8d4f..8a423b577ab2900962bde6cd22f28798066beb00 100644
--- a/src/vs/editor/browser/widget/diffEditorWidget.ts
+++ b/src/vs/editor/browser/widget/diffEditorWidget.ts
@@ -23,7 +23,7 @@ import { Decoration } from 'vs/editor/common/viewLayout/viewLineParts';
import { renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
import { CodeEditor } from 'vs/editor/browser/codeEditor';
-import { ViewLineToken, ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { Configuration } from 'vs/editor/browser/config/configuration';
import { Position } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection';
@@ -1885,12 +1885,12 @@ 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 lineTokens = new ViewLineTokens([new ViewLineToken(0, '')], 0, lineContent.length);
let actualDecorations = Decoration.filter(decorations, lineNumber, 1, lineContent.length + 1);
let r = renderViewLine(new RenderLineInput(
lineContent,
- lineTokens,
+ 0,
+ [new ViewLineToken(lineContent.length, '')],
actualDecorations,
tabSize,
config.fontInfo.spaceWidth,
diff --git a/src/vs/editor/common/core/lineTokens.ts b/src/vs/editor/common/core/lineTokens.ts
index f0030ed7cb1107df960d222587fbc7278b5dce92..b1cca283dd189cc20d5a54be34e5ad7ae6b0020e 100644
--- a/src/vs/editor/common/core/lineTokens.ts
+++ b/src/vs/editor/common/core/lineTokens.ts
@@ -122,6 +122,10 @@ export class LineTokens {
return this._text;
}
+ public getLineLength(): number {
+ return this._textLength;
+ }
+
public getTokenStartOffset(tokenIndex: number): number {
return this._tokens[(tokenIndex << 1)];
}
@@ -190,10 +194,10 @@ export class LineTokens {
}
public inflate(): ViewLineToken[] {
- return TokenMetadata.inflateArr(this._tokens);
+ return TokenMetadata.inflateArr(this._tokens, this._textLength);
}
- public sliceAndInflate(startOffset: number, endOffset: number, deltaStartIndex: number): ViewLineToken[] {
- return TokenMetadata.sliceAndInflate(this._tokens, startOffset, endOffset, deltaStartIndex);
+ public sliceAndInflate(startOffset: number, endOffset: number, deltaOffset: number): ViewLineToken[] {
+ return TokenMetadata.sliceAndInflate(this._tokens, startOffset, endOffset, deltaOffset, this._textLength);
}
}
diff --git a/src/vs/editor/common/core/viewLineToken.ts b/src/vs/editor/common/core/viewLineToken.ts
index 9113d2d52aea9ed7ec6cb35983ba0b6b96efa9ff..03643e032b46c833f1f27df7d16f3494c4e198c3 100644
--- a/src/vs/editor/common/core/viewLineToken.ts
+++ b/src/vs/editor/common/core/viewLineToken.ts
@@ -4,7 +4,10 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
-export class ViewLineToken2 {
+/**
+ * A token on a line.
+ */
+export class ViewLineToken {
_viewLineTokenBrand: void;
/**
@@ -17,74 +20,25 @@ export class ViewLineToken2 {
this.endIndex = endIndex;
this.type = type;
}
-}
-
-/**
- * A token on a line.
- */
-export class ViewLineToken {
- _oldViewLineTokenBrand: void;
-
- public readonly startIndex: number;
- public readonly type: string;
-
- constructor(startIndex: number, type: string) {
- this.startIndex = startIndex | 0;// @perf
- this.type = type;
- }
- public equals(other: ViewLineToken): boolean {
+ private static _equals(a: ViewLineToken, b: ViewLineToken): boolean {
return (
- this.startIndex === other.startIndex
- && this.type === other.type
+ a.endIndex === b.endIndex
+ && a.type === b.type
);
}
- public static equalsArray(a: ViewLineToken[], b: ViewLineToken[]): boolean {
- let aLen = a.length;
- let bLen = b.length;
+ public static equalsArr(a: ViewLineToken[], b: ViewLineToken[]): boolean {
+ const aLen = a.length;
+ const bLen = b.length;
if (aLen !== bLen) {
return false;
}
for (let i = 0; i < aLen; i++) {
- if (!a[i].equals(b[i])) {
+ if (!this._equals(a[i], b[i])) {
return false;
}
}
return true;
}
}
-
-export class ViewLineTokens {
- _viewLineTokensBrand: void;
-
- private _lineTokens: ViewLineToken[];
- private _fauxIndentLength: number;
- private _textLength: number;
-
- constructor(lineTokens: ViewLineToken[], fauxIndentLength: number, textLength: number) {
- this._lineTokens = lineTokens;
- this._fauxIndentLength = fauxIndentLength | 0;
- this._textLength = textLength | 0;
- }
-
- public getTokens(): ViewLineToken[] {
- return this._lineTokens;
- }
-
- public getFauxIndentLength(): number {
- return this._fauxIndentLength;
- }
-
- public getTextLength(): number {
- return this._textLength;
- }
-
- public equals(other: ViewLineTokens): boolean {
- return (
- this._fauxIndentLength === other._fauxIndentLength
- && this._textLength === other._textLength
- && ViewLineToken.equalsArray(this._lineTokens, other._lineTokens)
- );
- }
-}
diff --git a/src/vs/editor/common/model/tokensBinaryEncoding.ts b/src/vs/editor/common/model/tokensBinaryEncoding.ts
index 18884f1de393856e267799efd1f37dc25e8fdb4f..6876e6eb4508cb66be3e45b158fdb5a27c51fd85 100644
--- a/src/vs/editor/common/model/tokensBinaryEncoding.ts
+++ b/src/vs/editor/common/model/tokensBinaryEncoding.ts
@@ -71,36 +71,35 @@ export class TokenMetadata {
return className;
}
- public static inflateArr(tokens: Uint32Array): ViewLineToken[] {
- let tokenCount = (tokens.length >>> 1);
+ public static inflateArr(tokens: Uint32Array, lineLength: number): ViewLineToken[] {
let result: ViewLineToken[] = [];
- for (let i = 0; i < tokenCount; i++) {
- let startOffset = tokens[(i << 1)];
+ for (let i = 0, len = (tokens.length >>> 1); i < len; i++) {
+ let endOffset = (i + 1 < len ? tokens[((i + 1) << 1)] : lineLength);
let metadata = tokens[(i << 1) + 1];
- result[i] = new ViewLineToken(startOffset, this._getClassNameFromMetadata(metadata));
+ result[i] = new ViewLineToken(endOffset, this._getClassNameFromMetadata(metadata));
}
+
return result;
}
- public static sliceAndInflate(tokens: Uint32Array, startOffset: number, endOffset: number, deltaStartIndex: number): ViewLineToken[] {
+ public static sliceAndInflate(tokens: Uint32Array, startOffset: number, endOffset: number, deltaOffset: number, lineLength: number): ViewLineToken[] {
let tokenIndex = this.findIndexInSegmentsArray(tokens, startOffset);
let result: ViewLineToken[] = [], resultLen = 0;
- result[resultLen++] = new ViewLineToken(0, this._getClassNameFromMetadata(tokens[(tokenIndex << 1) + 1]));
-
- for (let i = tokenIndex + 1, len = (tokens.length >>> 1); i < len; i++) {
- let originalStartOffset = tokens[(i << 1)];
+ for (let i = tokenIndex, len = (tokens.length >>> 1); i < len; i++) {
+ let tokenStartOffset = tokens[(i << 1)];
- if (originalStartOffset >= endOffset) {
+ if (tokenStartOffset >= endOffset) {
break;
}
- let newStartOffset = originalStartOffset - startOffset + deltaStartIndex;
+ let tokenEndOffset = (i + 1 < len ? tokens[((i + 1) << 1)] : lineLength);
+ let newEndOffset = tokenEndOffset - startOffset + deltaOffset;
let metadata = tokens[(i << 1) + 1];
- result[resultLen++] = new ViewLineToken(newStartOffset, this._getClassNameFromMetadata(metadata));
+ result[resultLen++] = new ViewLineToken(newEndOffset, this._getClassNameFromMetadata(metadata));
}
return result;
diff --git a/src/vs/editor/common/modes/textToHtmlTokenizer.ts b/src/vs/editor/common/modes/textToHtmlTokenizer.ts
index 19795f0681a41e6ebeebc0f5587a6abda5687289..e81acfc98027f18b44656d719a096d77eb9bdce7 100644
--- a/src/vs/editor/common/modes/textToHtmlTokenizer.ts
+++ b/src/vs/editor/common/modes/textToHtmlTokenizer.ts
@@ -41,16 +41,11 @@ function _tokenizeToString(text: string, tokenizationSupport: ITokenizationSuppo
let viewLineTokens = lineTokens.inflate();
let startOffset = 0;
- let className = viewLineTokens[0].type;
-
- for (let j = 1, lenJ = viewLineTokens.length; j < lenJ; j++) {
- let viewLineToken = viewLineTokens[j];
-
- result += `${strings.escape(line.substring(startOffset, viewLineToken.startIndex))}`;
- startOffset = viewLineToken.startIndex;
- className = viewLineToken.type;
+ for (let j = 0, lenJ = viewLineTokens.length; j < lenJ; j++) {
+ const viewLineToken = viewLineTokens[j];
+ result += `${strings.escape(line.substring(startOffset, viewLineToken.endIndex))}`;
+ startOffset = viewLineToken.endIndex;
}
- result += `${strings.escape(line.substring(startOffset))}`;
currentState = tokenizationResult.endState;
}
diff --git a/src/vs/editor/common/viewLayout/viewLineRenderer.ts b/src/vs/editor/common/viewLayout/viewLineRenderer.ts
index 7992149c5ec62855596bb5dd0853372bbb00f24a..6f27d84803f5ea435b23bf4e45413136957647af 100644
--- a/src/vs/editor/common/viewLayout/viewLineRenderer.ts
+++ b/src/vs/editor/common/viewLayout/viewLineRenderer.ts
@@ -4,51 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
-import { ViewLineToken, ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+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 * as strings from 'vs/base/common/strings';
-
-
-class ViewLineToken2 {
- _viewLineTokenBrand: void;
-
- /**
- * last char index of this token (not inclusive).
- */
- public readonly endIndex: number;
- public readonly type: string;
-
- constructor(endIndex: number, type: string) {
- this.endIndex = endIndex;
- this.type = type;
- }
-}
-
-/**
- * TODO@Alex: transform please
- */
-function transformPlease(tokens: ViewLineToken[], len: number): ViewLineToken2[] {
- console.log(`input len::: `, len);
- console.log(`input here::: `, tokens);
- let result: ViewLineToken2[] = [];
- for (let tokenIndex = 0, tokensLen = tokens.length; tokenIndex < tokensLen; tokenIndex++) {
- if (tokens[tokenIndex].startIndex > len) {
- break;
- // throw new Error('TODO!');
- }
- let nextTokenStartIndex = (
- tokenIndex + 1 < tokensLen
- ? Math.min(len, tokens[tokenIndex + 1].startIndex)
- : len
- );
- result[tokenIndex] = new ViewLineToken2(nextTokenStartIndex, tokens[tokenIndex].type);
- }
- console.log(`result here:::: `, result);
- return result;
-}
-
export const enum RenderWhitespace {
None = 0,
Boundary = 1,
@@ -58,7 +18,8 @@ export const enum RenderWhitespace {
export class RenderLineInput {
public readonly lineContent: string;
- public readonly lineTokens: ViewLineTokens;
+ public readonly fauxIndentLength: number;
+ public readonly lineTokens: ViewLineToken[];
public readonly lineDecorations: Decoration[];
public readonly tabSize: number;
public readonly spaceWidth: number;
@@ -68,7 +29,8 @@ export class RenderLineInput {
constructor(
lineContent: string,
- lineTokens: ViewLineTokens,
+ fauxIndentLength: number,
+ lineTokens: ViewLineToken[],
lineDecorations: Decoration[],
tabSize: number,
spaceWidth: number,
@@ -77,6 +39,7 @@ export class RenderLineInput {
renderControlCharacters: boolean,
) {
this.lineContent = lineContent;
+ this.fauxIndentLength = fauxIndentLength;
this.lineTokens = lineTokens;
this.lineDecorations = lineDecorations;
this.tabSize = tabSize;
@@ -95,13 +58,14 @@ export class RenderLineInput {
public equals(other: RenderLineInput): boolean {
return (
this.lineContent === other.lineContent
+ && this.fauxIndentLength === other.fauxIndentLength
&& this.tabSize === other.tabSize
&& this.spaceWidth === other.spaceWidth
&& this.stopRenderingLineAfter === other.stopRenderingLineAfter
&& this.renderWhitespace === other.renderWhitespace
&& this.renderControlCharacters === other.renderControlCharacters
&& Decoration.equalsArr(this.lineDecorations, other.lineDecorations)
- && this.lineTokens.equals(other.lineTokens)
+ && ViewLineToken.equalsArr(this.lineTokens, other.lineTokens)
);
}
}
@@ -246,7 +210,7 @@ class ResolvedRenderLineInput {
public readonly lineContent: string,
public readonly len: number,
public readonly isOverflowing: boolean,
- public readonly tokens: ViewLineToken2[],
+ public readonly tokens: ViewLineToken[],
public readonly lineDecorations: Decoration[],
public readonly tabSize: number,
public readonly spaceWidth: number,
@@ -271,13 +235,10 @@ function resolveRenderLineInput(input: RenderLineInput): ResolvedRenderLineInput
len = lineContent.length;
}
- let tokens: ViewLineToken2[];
+ let tokens = removeOverflowing(input.lineTokens, len);
if (input.renderWhitespace === RenderWhitespace.All || input.renderWhitespace === RenderWhitespace.Boundary) {
- tokens = _applyRenderWhitespace(lineContent, len, transformPlease(input.lineTokens.getTokens(), len), input.lineTokens.getFauxIndentLength(), input.tabSize, input.renderWhitespace === RenderWhitespace.Boundary);
- } else {
- tokens = transformPlease(input.lineTokens.getTokens(), len);
+ tokens = _applyRenderWhitespace(lineContent, len, tokens, input.fauxIndentLength, input.tabSize, input.renderWhitespace === RenderWhitespace.Boundary);
}
-
if (input.lineDecorations.length > 0) {
tokens = _applyInlineDecorations(lineContent, len, tokens, input.lineDecorations);
}
@@ -295,15 +256,38 @@ function resolveRenderLineInput(input: RenderLineInput): ResolvedRenderLineInput
);
}
-function _applyRenderWhitespace(lineContent: string, len: number, tokens: ViewLineToken2[], fauxIndentLength: number, tabSize: number, onlyBoundary: boolean): ViewLineToken2[] {
+function removeOverflowing(tokens: ViewLineToken[], len: number): ViewLineToken[] {
+ if (tokens.length === 0) {
+ return tokens;
+ }
+ if (tokens[tokens.length - 1].endIndex === len) {
+ return tokens;
+ }
+ let result: ViewLineToken[] = [];
+ for (let tokenIndex = 0, tokensLen = tokens.length; tokenIndex < tokensLen; tokenIndex++) {
+ const endIndex = tokens[tokenIndex].endIndex;
+ if (endIndex === len) {
+ result[tokenIndex] = tokens[tokenIndex];
+ break;
+ }
+ if (endIndex > len) {
+ result[tokenIndex] = new ViewLineToken(len, tokens[tokenIndex].type);
+ break;
+ }
+ result[tokenIndex] = tokens[tokenIndex];
+ }
+ return result;
+}
+
+function _applyRenderWhitespace(lineContent: string, len: number, tokens: ViewLineToken[], fauxIndentLength: number, tabSize: number, onlyBoundary: boolean): ViewLineToken[] {
- let result: ViewLineToken2[] = [], resultLen = 0;
+ let result: ViewLineToken[] = [], resultLen = 0;
let tokenIndex = 0;
let tokenType = tokens[tokenIndex].type;
let tokenEndIndex = tokens[tokenIndex].endIndex;
if (fauxIndentLength > 0) {
- result[resultLen++] = new ViewLineToken2(fauxIndentLength, '');
+ result[resultLen++] = new ViewLineToken(fauxIndentLength, '');
}
let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
@@ -359,13 +343,13 @@ function _applyRenderWhitespace(lineContent: string, len: number, tokens: ViewLi
// was in whitespace token
if (!isInWhitespace || tmpIndent >= tabSize) {
// leaving whitespace token or entering a new indent
- result[resultLen++] = new ViewLineToken2(charIndex, 'vs-whitespace');
+ result[resultLen++] = new ViewLineToken(charIndex, 'vs-whitespace');
tmpIndent = tmpIndent % tabSize;
}
} else {
// was in regular token
if (charIndex === tokenEndIndex || (isInWhitespace && charIndex > fauxIndentLength)) {
- result[resultLen++] = new ViewLineToken2(charIndex, tokenType);
+ result[resultLen++] = new ViewLineToken(charIndex, tokenType);
tmpIndent = tmpIndent % tabSize;
}
}
@@ -387,22 +371,22 @@ function _applyRenderWhitespace(lineContent: string, len: number, tokens: ViewLi
if (wasInWhitespace) {
// was in whitespace token
- result[resultLen++] = new ViewLineToken2(len, 'vs-whitespace');
+ result[resultLen++] = new ViewLineToken(len, 'vs-whitespace');
} else {
// was in regular token
- result[resultLen++] = new ViewLineToken2(len, tokenType);
+ result[resultLen++] = new ViewLineToken(len, tokenType);
}
return result;
}
-function _applyInlineDecorations(lineContent: string, len: number, tokens: ViewLineToken2[], _lineDecorations: Decoration[]): ViewLineToken2[] {
+function _applyInlineDecorations(lineContent: string, len: number, tokens: ViewLineToken[], _lineDecorations: Decoration[]): ViewLineToken[] {
_lineDecorations.sort(Decoration.compare);
const lineDecorations = LineDecorationsNormalizer.normalize(_lineDecorations);
const lineDecorationsLen = lineDecorations.length;
let lineDecorationIndex = 0;
- let result: ViewLineToken2[] = [], resultLen = 0, lastResultEndIndex = 0;
+ let result: ViewLineToken[] = [], resultLen = 0, lastResultEndIndex = 0;
for (let tokenIndex = 0, len = tokens.length; tokenIndex < len; tokenIndex++) {
const token = tokens[tokenIndex];
const tokenEndIndex = token.endIndex;
@@ -413,12 +397,12 @@ function _applyInlineDecorations(lineContent: string, len: number, tokens: ViewL
if (lineDecoration.startOffset > lastResultEndIndex) {
lastResultEndIndex = lineDecoration.startOffset;
- result[resultLen++] = new ViewLineToken2(lastResultEndIndex, tokenType);
+ result[resultLen++] = new ViewLineToken(lastResultEndIndex, tokenType);
}
if (lineDecoration.endOffset + 1 < tokenEndIndex) {
lastResultEndIndex = lineDecoration.endOffset + 1;
- result[resultLen++] = new ViewLineToken2(lastResultEndIndex, tokenType + ' ' + lineDecoration.className);
+ result[resultLen++] = new ViewLineToken(lastResultEndIndex, tokenType + ' ' + lineDecoration.className);
lineDecorationIndex++;
} else {
break;
@@ -427,7 +411,7 @@ function _applyInlineDecorations(lineContent: string, len: number, tokens: ViewL
if (tokenEndIndex > lastResultEndIndex) {
lastResultEndIndex = tokenEndIndex;
- result[resultLen++] = new ViewLineToken2(lastResultEndIndex, tokenType);
+ result[resultLen++] = new ViewLineToken(lastResultEndIndex, tokenType);
}
}
diff --git a/src/vs/editor/common/viewModel/filteredLineTokens.ts b/src/vs/editor/common/viewModel/filteredLineTokens.ts
deleted file mode 100644
index 9aa5812f19550f8e4b9c74d929f1bd7a3e96e1cd..0000000000000000000000000000000000000000
--- a/src/vs/editor/common/viewModel/filteredLineTokens.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-'use strict';
-
-import { ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
-import { LineTokens } from 'vs/editor/common/core/lineTokens';
-
-export class FilteredLineTokens {
- /**
- * [startOffset; endOffset) (i.e. do not include endOffset)
- */
- public static create(original: LineTokens, startOffset: number, endOffset: number, deltaStartIndex: number): ViewLineTokens {
- let inflatedTokens = original.sliceAndInflate(startOffset, endOffset, deltaStartIndex);
- return new ViewLineTokens(
- inflatedTokens,
- deltaStartIndex,
- endOffset - startOffset + deltaStartIndex
- );
- }
-}
-
-export class IdentityFilteredLineTokens {
-
- public static create(original: LineTokens, textLength: number): ViewLineTokens {
- let inflatedTokens = original.inflate();
- return new ViewLineTokens(
- inflatedTokens,
- 0,
- textLength
- );
- }
-}
diff --git a/src/vs/editor/common/viewModel/splitLinesCollection.ts b/src/vs/editor/common/viewModel/splitLinesCollection.ts
index 66edc720e9cc2fa74dec4a2044fd39c702f7d064..1715ce7ef3c6c54bc16e02747e632f735c4b3407 100644
--- a/src/vs/editor/common/viewModel/splitLinesCollection.ts
+++ b/src/vs/editor/common/viewModel/splitLinesCollection.ts
@@ -8,10 +8,9 @@ import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { LineTokens } from 'vs/editor/common/core/lineTokens';
-import { FilteredLineTokens, IdentityFilteredLineTokens } from 'vs/editor/common/viewModel/filteredLineTokens';
import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer';
import { ILinesCollection } from 'vs/editor/common/viewModel/viewModelImpl';
-import { ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
export class OutputPosition {
_outputPositionBrand: void;
@@ -49,7 +48,7 @@ export interface ISplitLine {
getOutputLineContent(model: IModel, myLineNumber: number, outputLineIndex: number): string;
getOutputLineMinColumn(model: IModel, myLineNumber: number, outputLineIndex: number): number;
getOutputLineMaxColumn(model: IModel, myLineNumber: number, outputLineIndex: number): number;
- getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineTokens;
+ getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineToken[];
getInputColumnOfOutputPosition(outputLineIndex: number, outputColumn: number): number;
getOutputPositionOfInputPosition(deltaLineNumber: number, inputColumn: number): Position;
}
@@ -87,8 +86,9 @@ class VisibleIdentitySplitLine implements ISplitLine {
return model.getLineMaxColumn(myLineNumber);
}
- public getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineTokens {
- return IdentityFilteredLineTokens.create(model.getLineTokens(myLineNumber, true), model.getLineMaxColumn(myLineNumber) - 1);
+ public getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineToken[] {
+ let lineTokens = model.getLineTokens(myLineNumber, true);
+ return lineTokens.inflate();
}
public getInputColumnOfOutputPosition(outputLineIndex: number, outputColumn: number): number {
@@ -133,7 +133,7 @@ class InvisibleIdentitySplitLine implements ISplitLine {
throw new Error('Not supported');
}
- public getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineTokens {
+ public getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineToken[] {
throw new Error('Not supported');
}
@@ -223,7 +223,7 @@ export class SplitLine implements ISplitLine {
return this.getOutputLineContent(model, myLineNumber, outputLineIndex).length + 1;
}
- public getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineTokens {
+ public getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineToken[] {
if (!this._isVisible) {
throw new Error('Not supported');
}
@@ -233,7 +233,9 @@ export class SplitLine implements ISplitLine {
if (outputLineIndex > 0) {
deltaStartIndex = this.wrappedIndentLength;
}
- return FilteredLineTokens.create(model.getLineTokens(myLineNumber, true), startOffset, endOffset, deltaStartIndex);
+
+ let lineTokens = model.getLineTokens(myLineNumber, true);
+ return lineTokens.sliceAndInflate(startOffset, endOffset, deltaStartIndex);
}
public getInputColumnOfOutputPosition(outputLineIndex: number, outputColumn: number): number {
@@ -691,7 +693,7 @@ export class SplitLinesCollection implements ILinesCollection {
return this.lines[lineIndex].getOutputLineMaxColumn(this.model, lineIndex + 1, remainder);
}
- public getOutputLineTokens(outputLineNumber: number): ViewLineTokens {
+ public getOutputLineTokens(outputLineNumber: number): ViewLineToken[] {
this._ensureValidState();
outputLineNumber = this._toValidOutputLineNumber(outputLineNumber);
let r = this.prefixSumComputer.getIndexOf(outputLineNumber - 1);
diff --git a/src/vs/editor/common/viewModel/viewModel.ts b/src/vs/editor/common/viewModel/viewModel.ts
index 30c689fee8df89051b06205d67ba50ac454de7db..dd4aab6550cfe00e4423cc41019023c6fa0941d1 100644
--- a/src/vs/editor/common/viewModel/viewModel.ts
+++ b/src/vs/editor/common/viewModel/viewModel.ts
@@ -6,7 +6,7 @@
import { IEventEmitter } from 'vs/base/common/eventEmitter';
import { IModelDecoration, EndOfLinePreference, IPosition } from 'vs/editor/common/editorCommon';
-import { ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
@@ -31,7 +31,7 @@ export interface IViewModel extends IEventEmitter {
getLineMaxColumn(lineNumber: number): number;
getLineFirstNonWhitespaceColumn(lineNumber: number): number;
getLineLastNonWhitespaceColumn(lineNumber: number): number;
- getLineTokens(lineNumber: number): ViewLineTokens;
+ getLineTokens(lineNumber: number): ViewLineToken[];
getDecorationsViewportData(startLineNumber: number, endLineNumber: number): IDecorationsViewportData;
getLineRenderLineNumber(lineNumber: number): string;
/**
diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts
index 62eaaf2ee3ca589e2450d88e6e619e3ce5ea9209..7d00693222ebb6ea9034814727264676f0c9ccc1 100644
--- a/src/vs/editor/common/viewModel/viewModelImpl.ts
+++ b/src/vs/editor/common/viewModel/viewModelImpl.ts
@@ -14,7 +14,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import { ViewModelCursors } from 'vs/editor/common/viewModel/viewModelCursors';
import { ViewModelDecorations } from 'vs/editor/common/viewModel/viewModelDecorations';
import { ViewModelDecoration, IDecorationsViewportData, IViewModel } from 'vs/editor/common/viewModel/viewModel';
-import { ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
export interface ILinesCollection {
setTabSize(newTabSize: number, emit: (evenType: string, payload: any) => void): boolean;
@@ -30,7 +30,7 @@ export interface ILinesCollection {
getOutputIndentGuide(outputLineNumber: number): number;
getOutputLineMinColumn(outputLineNumber: number): number;
getOutputLineMaxColumn(outputLineNumber: number): number;
- getOutputLineTokens(outputLineNumber: number): ViewLineTokens;
+ getOutputLineTokens(outputLineNumber: number): ViewLineToken[];
convertOutputPositionToInputPosition(viewLineNumber: number, viewColumn: number): Position;
convertInputPositionToOutputPosition(inputLineNumber: number, inputColumn: number): Position;
setHiddenAreas(ranges: editorCommon.IRange[], emit: (evenType: string, payload: any) => void): void;
@@ -445,7 +445,7 @@ export class ViewModel extends EventEmitter implements IViewModel {
return result + 2;
}
- public getLineTokens(lineNumber: number): ViewLineTokens {
+ public getLineTokens(lineNumber: number): ViewLineToken[] {
return this.lines.getOutputLineTokens(lineNumber);
}
diff --git a/src/vs/editor/test/common/model/model.line.test.ts b/src/vs/editor/test/common/model/model.line.test.ts
index 0210b17139eae2b2a788eda070eb9ddf60ef197e..49675d80ccde5f5423cddc7702771ee962e6cd36 100644
--- a/src/vs/editor/test/common/model/model.line.test.ts
+++ b/src/vs/editor/test/common/model/model.line.test.ts
@@ -9,15 +9,12 @@ import { LineTokens } from 'vs/editor/common/core/lineTokens';
import { ModelLine, ILineEdit, LineMarker, MarkersTracker } from 'vs/editor/common/model/modelLine';
import { MetadataConsts } from 'vs/editor/common/modes';
import { Position } from 'vs/editor/common/core/position';
+import { TokenMetadata } from 'vs/editor/common/model/tokensBinaryEncoding';
-function assertLineTokens(actual: LineTokens, expected: TestToken[]): void {
- let inflatedActual = actual.inflate();
- assert.deepEqual(inflatedActual, expected.map((token) => {
- return {
- startIndex: token.startOffset,
- type: 'mtk' + token.color
- };
- }), 'Line tokens are equal');
+function assertLineTokens(_actual: LineTokens, _expected: TestToken[]): void {
+ let expected = TokenMetadata.inflateArr(TestToken.toTokens(_expected), _actual.getLineLength());
+ let actual = _actual.inflate();
+ assert.deepEqual(actual, expected);
}
const NO_TAB_SIZE = 0;
diff --git a/src/vs/editor/test/common/model/textModelWithTokens.test.ts b/src/vs/editor/test/common/model/textModelWithTokens.test.ts
index 35032616b4a20ca794c7ec94b1104aefb59f1f75..4f38ca260e6f639ae89b3a947b969a6be969a0b8 100644
--- a/src/vs/editor/test/common/model/textModelWithTokens.test.ts
+++ b/src/vs/editor/test/common/model/textModelWithTokens.test.ts
@@ -293,18 +293,18 @@ suite('TextModelWithTokens regression tests', () => {
let model = Model.createFromString('A model with\ntwo lines');
- assertViewLineTokens(model, 1, true, [new ViewLineToken(0, 'mtk1')]);
- assertViewLineTokens(model, 2, true, [new ViewLineToken(0, 'mtk1')]);
+ assertViewLineTokens(model, 1, true, [new ViewLineToken(12, 'mtk1')]);
+ assertViewLineTokens(model, 2, true, [new ViewLineToken(9, 'mtk1')]);
model.setMode(languageIdentifier1);
- assertViewLineTokens(model, 1, true, [new ViewLineToken(0, 'mtk11')]);
- assertViewLineTokens(model, 2, true, [new ViewLineToken(0, 'mtk12')]);
+ assertViewLineTokens(model, 1, true, [new ViewLineToken(12, 'mtk11')]);
+ assertViewLineTokens(model, 2, true, [new ViewLineToken(9, 'mtk12')]);
model.setMode(languageIdentifier2);
- assertViewLineTokens(model, 1, false, [new ViewLineToken(0, 'mtk1')]);
- assertViewLineTokens(model, 2, false, [new ViewLineToken(0, 'mtk1')]);
+ assertViewLineTokens(model, 1, false, [new ViewLineToken(12, 'mtk1')]);
+ assertViewLineTokens(model, 2, false, [new ViewLineToken(9, 'mtk1')]);
model.dispose();
registration1.dispose();
diff --git a/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts b/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts
index 6b663b8ecb5f4e2d85fab23d1d35330987b007cd..8057407ddebfd1f1e98e8ee2089ba402fc6f48f3 100644
--- a/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts
+++ b/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts
@@ -8,7 +8,7 @@ import * as assert from 'assert';
import { DecorationSegment, LineDecorationsNormalizer, Decoration } from 'vs/editor/common/viewLayout/viewLineParts';
import { Range } from 'vs/editor/common/core/range';
import { RenderLineInput, renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
-import { ViewLineToken, ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel';
suite('Editor ViewLayout - ViewLineParts', () => {
@@ -58,7 +58,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
function testCreateLineParts(lineContent: string, tokens: ViewLineToken[], fauxIndentLength: number, renderWhitespace: 'none' | 'boundary' | 'all', expected: string): void {
let actual = renderViewLine(new RenderLineInput(
lineContent,
- new ViewLineTokens(tokens, fauxIndentLength, lineContent.length),
+ fauxIndentLength,
+ tokens,
[],
4,
10,
@@ -74,7 +75,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
'Hello world!',
[
- new ViewLineToken(0, '')
+ new ViewLineToken(12, '')
],
0,
'none',
@@ -89,8 +90,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
'Hello world!',
[
- new ViewLineToken(0, 'a'),
- new ViewLineToken(6, 'b')
+ new ViewLineToken(6, 'a'),
+ new ViewLineToken(12, 'b')
],
0,
'none',
@@ -106,9 +107,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
' Hello world! ',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(4, 'a'),
- new ViewLineToken(6, 'b')
+ new ViewLineToken(4, ''),
+ new ViewLineToken(6, 'a'),
+ new ViewLineToken(20, 'b')
],
0,
'boundary',
@@ -126,9 +127,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
' Hello world! ',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(8, 'a'),
- new ViewLineToken(10, 'b')
+ new ViewLineToken(8, ''),
+ new ViewLineToken(10, 'a'),
+ new ViewLineToken(28, 'b')
],
0,
'boundary',
@@ -148,9 +149,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
'\t\tHello world!\t',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(2, 'a'),
- new ViewLineToken(4, 'b')
+ new ViewLineToken(2, ''),
+ new ViewLineToken(4, 'a'),
+ new ViewLineToken(15, 'b')
],
0,
'boundary',
@@ -169,9 +170,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
' \t\t Hello world! \t \t \t ',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(6, 'a'),
- new ViewLineToken(8, 'b')
+ new ViewLineToken(6, ''),
+ new ViewLineToken(8, 'a'),
+ new ViewLineToken(31, 'b')
],
0,
'boundary',
@@ -195,9 +196,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
'\t\t Hello world! \t \t \t ',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(4, 'a'),
- new ViewLineToken(6, 'b')
+ new ViewLineToken(4, ''),
+ new ViewLineToken(6, 'a'),
+ new ViewLineToken(29, 'b')
],
2,
'boundary',
@@ -220,9 +221,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
'it it it it',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(6, 'a'),
- new ViewLineToken(7, 'b')
+ new ViewLineToken(6, ''),
+ new ViewLineToken(7, 'a'),
+ new ViewLineToken(13, 'b')
],
0,
'boundary',
@@ -244,9 +245,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
testCreateLineParts(
' Hello world!\t',
[
- new ViewLineToken(0, ''),
- new ViewLineToken(4, 'a'),
- new ViewLineToken(6, 'b')
+ new ViewLineToken(4, ''),
+ new ViewLineToken(6, 'a'),
+ new ViewLineToken(14, 'b')
],
0,
'all',
@@ -266,7 +267,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
test('createLineParts can handle unsorted inline decorations', () => {
let actual = renderViewLine(new RenderLineInput(
'Hello world',
- new ViewLineTokens([new ViewLineToken(0, '')], 0, 'Hello world'.length),
+ 0,
+ [new ViewLineToken(11, '')],
[
new Decoration(5, 7, 'a'),
new Decoration(1, 3, 'b'),
@@ -369,7 +371,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
function createTestGetColumnOfLinePartOffset(lineContent: string, tabSize: number, parts: ViewLineToken[]): (partIndex: number, partLength: number, offset: number, expected: number) => void {
let renderLineOutput = renderViewLine(new RenderLineInput(
lineContent,
- new ViewLineTokens(parts, 0, lineContent.length),
+ 0,
+ parts,
[],
tabSize,
10,
@@ -390,7 +393,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'hello world',
4,
[
- new ViewLineToken(0, 'aToken')
+ new ViewLineToken(11, 'aToken')
]
);
testGetColumnOfLinePartOffset(0, 11, 0, 1);
@@ -412,12 +415,12 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'var x = 3;',
4,
[
- new ViewLineToken(0, 'meta type js storage var expr'),
- new ViewLineToken(3, 'meta js var expr'),
- new ViewLineToken(4, 'meta js var expr var-single-variable variable'),
- new ViewLineToken(5, 'meta js var expr var-single-variable'),
- new ViewLineToken(8, 'meta js var expr var-single-variable constant numeric'),
- new ViewLineToken(9, ''),
+ new ViewLineToken(3, 'meta type js storage var expr'),
+ new ViewLineToken(4, 'meta js var expr'),
+ new ViewLineToken(5, 'meta js var expr var-single-variable variable'),
+ new ViewLineToken(8, 'meta js var expr var-single-variable'),
+ new ViewLineToken(9, 'meta js var expr var-single-variable constant numeric'),
+ new ViewLineToken(10, ''),
]
);
testGetColumnOfLinePartOffset(0, 3, 0, 1);
@@ -443,7 +446,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'\t',
6,
[
- new ViewLineToken(0, 'vs-whitespace')
+ new ViewLineToken(1, 'vs-whitespace')
]
);
testGetColumnOfLinePartOffset(0, 6, 0, 1);
@@ -460,8 +463,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'\tfunction',
4,
[
- new ViewLineToken(0, ''),
- new ViewLineToken(1, 'meta type js function storage'),
+ new ViewLineToken(1, ''),
+ new ViewLineToken(9, 'meta type js function storage'),
]
);
testGetColumnOfLinePartOffset(0, 4, 0, 1);
@@ -485,8 +488,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'\t\tfunction',
4,
[
- new ViewLineToken(0, ''),
- new ViewLineToken(2, 'meta type js function storage'),
+ new ViewLineToken(2, ''),
+ new ViewLineToken(10, 'meta type js function storage'),
]
);
testGetColumnOfLinePartOffset(0, 8, 0, 1);
diff --git a/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts b/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
index c6f3fbf2cba2fa009ae1c98be27b5a4f73b34893..fa0c12db0066d0a4461735e0b01c04792161547f 100644
--- a/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
+++ b/src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
@@ -6,19 +6,20 @@
import * as assert from 'assert';
import { renderViewLine, RenderLineInput, CharacterMapping } from 'vs/editor/common/viewLayout/viewLineRenderer';
-import { ViewLineToken, ViewLineTokens } from 'vs/editor/common/core/viewLineToken';
+import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { CharCode } from 'vs/base/common/charCode';
suite('viewLineRenderer.renderLine', () => {
- function createPart(startIndex: number, type: string): ViewLineToken {
- return new ViewLineToken(startIndex, type);
+ function createPart(endIndex: number, type: string): ViewLineToken {
+ return new ViewLineToken(endIndex, type);
}
function assertCharacterReplacement(lineContent: string, tabSize: number, expected: string, expectedCharOffsetInPart: number[][]): void {
let _actual = renderViewLine(new RenderLineInput(
lineContent,
- new ViewLineTokens([new ViewLineToken(0, '')], 0, lineContent.length),
+ 0,
+ [new ViewLineToken(lineContent.length, '')],
[],
tabSize,
0,
@@ -61,7 +62,8 @@ suite('viewLineRenderer.renderLine', () => {
function assertParts(lineContent: string, tabSize: number, parts: ViewLineToken[], expected: string, expectedCharOffsetInPart: number[][]): void {
let _actual = renderViewLine(new RenderLineInput(
lineContent,
- new ViewLineTokens(parts, 0, lineContent.length),
+ 0,
+ parts,
[],
tabSize,
0,
@@ -79,34 +81,35 @@ suite('viewLineRenderer.renderLine', () => {
});
test('uses part type', () => {
- assertParts('x', 4, [createPart(0, 'y')], 'x', [[0, 1]]);
- assertParts('x', 4, [createPart(0, 'aAbBzZ0123456789-cC')], 'x', [[0, 1]]);
- assertParts('x', 4, [createPart(0, ' ')], 'x', [[0, 1]]);
+ assertParts('x', 4, [createPart(1, 'y')], 'x', [[0, 1]]);
+ assertParts('x', 4, [createPart(1, 'aAbBzZ0123456789-cC')], 'x', [[0, 1]]);
+ assertParts('x', 4, [createPart(1, ' ')], 'x', [[0, 1]]);
});
test('two parts', () => {
- assertParts('xy', 4, [createPart(0, 'a'), createPart(1, 'b')], 'xy', [[0], [0, 1]]);
- assertParts('xyz', 4, [createPart(0, 'a'), createPart(1, 'b')], 'xyz', [[0], [0, 1, 2]]);
- assertParts('xyz', 4, [createPart(0, 'a'), createPart(2, 'b')], 'xyz', [[0, 1], [0, 1]]);
+ assertParts('xy', 4, [createPart(1, 'a'), createPart(2, 'b')], 'xy', [[0], [0, 1]]);
+ assertParts('xyz', 4, [createPart(1, 'a'), createPart(3, 'b')], 'xyz', [[0], [0, 1, 2]]);
+ assertParts('xyz', 4, [createPart(2, 'a'), createPart(3, 'b')], 'xyz', [[0, 1], [0, 1]]);
});
test('overflow', () => {
let _actual = renderViewLine(new RenderLineInput(
'Hello world!',
- new ViewLineTokens([
- createPart(0, '0'),
- createPart(1, '1'),
- createPart(2, '2'),
- createPart(3, '3'),
- createPart(4, '4'),
- createPart(5, '5'),
- createPart(6, '6'),
- createPart(7, '7'),
- createPart(8, '8'),
- createPart(9, '9'),
- createPart(10, '10'),
- createPart(11, '11'),
- ], 0, 'Hello world!'.length),
+ 0,
+ [
+ createPart(1, '0'),
+ createPart(2, '1'),
+ createPart(3, '2'),
+ createPart(4, '3'),
+ createPart(5, '4'),
+ createPart(6, '5'),
+ createPart(7, '6'),
+ createPart(8, '7'),
+ createPart(9, '8'),
+ createPart(10, '9'),
+ createPart(11, '10'),
+ createPart(12, '11'),
+ ],
[],
4,
10,
@@ -139,18 +142,18 @@ suite('viewLineRenderer.renderLine', () => {
test('typical line', () => {
let lineText = '\t export class Game { // http://test.com ';
let lineParts = [
- createPart(0, 'block meta ts'),
- createPart(5, 'block declaration meta modifier object storage ts'),
- createPart(11, 'block declaration meta object ts'),
- createPart(12, 'block declaration meta object storage type ts'),
- createPart(17, 'block declaration meta object ts'),
- createPart(18, 'block class declaration entity meta name object ts'),
- createPart(22, 'block declaration meta object ts'),
- createPart(23, 'delimiter curly typescript'),
- createPart(24, 'block body declaration meta object ts'),
- createPart(25, 'block body comment declaration line meta object ts'),
- createPart(28, 'block body comment declaration line meta object ts detected-link'),
- createPart(43, 'block body comment declaration line meta object ts'),
+ createPart(5, 'block meta ts'),
+ createPart(11, 'block declaration meta modifier object storage ts'),
+ createPart(12, 'block declaration meta object ts'),
+ createPart(17, 'block declaration meta object storage type ts'),
+ createPart(18, 'block declaration meta object ts'),
+ createPart(22, 'block class declaration entity meta name object ts'),
+ createPart(23, 'block declaration meta object ts'),
+ createPart(24, 'delimiter curly typescript'),
+ createPart(25, 'block body declaration meta object ts'),
+ createPart(28, 'block body comment declaration line meta object ts'),
+ createPart(43, 'block body comment declaration line meta object ts detected-link'),
+ createPart(48, 'block body comment declaration line meta object ts'),
];
let expectedOutput = [
'→ ',
@@ -187,7 +190,8 @@ suite('viewLineRenderer.renderLine', () => {
let _actual = renderViewLine(new RenderLineInput(
lineText,
- new ViewLineTokens(lineParts, 0, lineText.length),
+ 0,
+ lineParts,
[],
4,
10,
@@ -204,16 +208,16 @@ suite('viewLineRenderer.renderLine', () => {
let lineText = '\t\t\tcursorStyle:\t\t\t\t\t\t(prevOpts.cursorStyle !== newOpts.cursorStyle),';
let lineParts = [
- createPart(0, 'block body decl declaration meta method object ts'), // 3 chars
- createPart(3, 'block body decl declaration member meta method object ts'), // 12 chars
- createPart(15, 'block body decl declaration member meta method object ts'), // 6 chars
- createPart(21, 'delimiter paren typescript'), // 1 char
- createPart(22, 'block body decl declaration member meta method object ts'), // 21 chars
- createPart(43, 'block body comparison decl declaration keyword member meta method object operator ts'), // 2 chars
- createPart(45, 'block body comparison decl declaration keyword member meta method object operator ts'), // 1 char
- createPart(46, 'block body decl declaration member meta method object ts'), // 20 chars
- createPart(66, 'delimiter paren typescript'), // 1 char
- createPart(67, 'block body decl declaration meta method object ts'), // 2 chars
+ createPart(3, 'block body decl declaration meta method object ts'), // 3 chars
+ createPart(15, 'block body decl declaration member meta method object ts'), // 12 chars
+ createPart(21, 'block body decl declaration member meta method object ts'), // 6 chars
+ createPart(22, 'delimiter paren typescript'), // 1 char
+ createPart(43, 'block body decl declaration member meta method object ts'), // 21 chars
+ createPart(45, 'block body comparison decl declaration keyword member meta method object operator ts'), // 2 chars
+ createPart(46, 'block body comparison decl declaration keyword member meta method object operator ts'), // 1 char
+ createPart(66, 'block body decl declaration member meta method object ts'), // 20 chars
+ createPart(67, 'delimiter paren typescript'), // 1 char
+ createPart(68, 'block body decl declaration meta method object ts'), // 2 chars
];
let expectedOutput = [
' ',
@@ -242,7 +246,8 @@ suite('viewLineRenderer.renderLine', () => {
let _actual = renderViewLine(new RenderLineInput(
lineText,
- new ViewLineTokens(lineParts, 0, lineText.length),
+ 0,
+ lineParts,
[],
4,
10,
@@ -259,16 +264,16 @@ suite('viewLineRenderer.renderLine', () => {
let lineText = ' \t\t\tcursorStyle:\t\t\t\t\t\t(prevOpts.cursorStyle !== newOpts.cursorStyle),';
let lineParts = [
- createPart(0, 'block body decl declaration meta method object ts'), // 4 chars
- createPart(4, 'block body decl declaration member meta method object ts'), // 12 chars
- createPart(16, 'block body decl declaration member meta method object ts'), // 6 chars
- createPart(22, 'delimiter paren typescript'), // 1 char
- createPart(23, 'block body decl declaration member meta method object ts'), // 21 chars
- createPart(44, 'block body comparison decl declaration keyword member meta method object operator ts'), // 2 chars
- createPart(46, 'block body comparison decl declaration keyword member meta method object operator ts'), // 1 char
- createPart(47, 'block body decl declaration member meta method object ts'), // 20 chars
- createPart(67, 'delimiter paren typescript'), // 1 char
- createPart(68, 'block body decl declaration meta method object ts'), // 2 chars
+ createPart(4, 'block body decl declaration meta method object ts'), // 4 chars
+ createPart(16, 'block body decl declaration member meta method object ts'), // 12 chars
+ createPart(22, 'block body decl declaration member meta method object ts'), // 6 chars
+ createPart(23, 'delimiter paren typescript'), // 1 char
+ createPart(44, 'block body decl declaration member meta method object ts'), // 21 chars
+ createPart(46, 'block body comparison decl declaration keyword member meta method object operator ts'), // 2 chars
+ createPart(47, 'block body comparison decl declaration keyword member meta method object operator ts'), // 1 char
+ createPart(67, 'block body decl declaration member meta method object ts'), // 20 chars
+ createPart(68, 'delimiter paren typescript'), // 1 char
+ createPart(69, 'block body decl declaration meta method object ts'), // 2 chars
];
let expectedOutput = [
' ',
@@ -297,7 +302,8 @@ suite('viewLineRenderer.renderLine', () => {
let _actual = renderViewLine(new RenderLineInput(
lineText,
- new ViewLineTokens(lineParts, 0, lineText.length),
+ 0,
+ lineParts,
[],
4,
10,