diff --git a/src/vs/editor/common/core/lineTokens.ts b/src/vs/editor/common/core/lineTokens.ts index 41022d13f8f..e989321930f 100644 --- a/src/vs/editor/common/core/lineTokens.ts +++ b/src/vs/editor/common/core/lineTokens.ts @@ -13,6 +13,7 @@ export interface IViewLineTokens { getClassName(tokenIndex: number): string; getInlineStyle(tokenIndex: number, colorMap: string[]): string; findTokenIndexAtOffset(offset: number): number; + getLineContent(): string; } export class LineTokens implements IViewLineTokens { @@ -246,6 +247,10 @@ export class SlicedLineTokens implements IViewLineTokens { } } + public getLineContent(): string { + return this._source.getLineContent().substring(this._startOffset, this._endOffset); + } + public equals(other: IViewLineTokens): boolean { if (other instanceof SlicedLineTokens) { return ( diff --git a/src/vs/editor/common/viewModel/modelLineProjection.ts b/src/vs/editor/common/viewModel/modelLineProjection.ts index fc134fe7ba4..ca0154bfc88 100644 --- a/src/vs/editor/common/viewModel/modelLineProjection.ts +++ b/src/vs/editor/common/viewModel/modelLineProjection.ts @@ -147,7 +147,6 @@ export class ModelLineProjection implements IModelLineProjection { const injectionOffsets = lineBreakData.injectionOffsets; const injectionOptions = lineBreakData.injectionOptions; - let lineContent: string; let tokens: IViewLineTokens; let inlineDecorations: null | SingleLineInlineDecoration[]; if (injectionOffsets) { @@ -160,7 +159,6 @@ export class ModelLineProjection implements IModelLineProjection { const lineStartOffsetInInputWithInjections = outputLineIndex > 0 ? lineBreakData.breakOffsets[outputLineIndex - 1] : 0; const lineEndOffsetInInputWithInjections = lineBreakData.breakOffsets[outputLineIndex]; - lineContent = lineTokens.getLineContent().substring(lineStartOffsetInInputWithInjections, lineEndOffsetInInputWithInjections); tokens = lineTokens.sliceAndInflate(lineStartOffsetInInputWithInjections, lineEndOffsetInInputWithInjections, deltaStartIndex); inlineDecorations = new Array(); @@ -194,16 +192,11 @@ export class ModelLineProjection implements IModelLineProjection { const startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex); const endOffset = this.getInputEndOffsetOfOutputLineIndex(outputLineIndex); const lineTokens = model.getLineTokens(modelLineNumber); - lineContent = model.getValueInRange({ - startLineNumber: modelLineNumber, - startColumn: startOffset + 1, - endLineNumber: modelLineNumber, - endColumn: endOffset + 1 - }); tokens = lineTokens.sliceAndInflate(startOffset, endOffset, deltaStartIndex); inlineDecorations = null; } + let lineContent = tokens.getLineContent(); if (outputLineIndex > 0) { lineContent = spaces(lineBreakData.wrappedTextIndentLength) + lineContent; } diff --git a/src/vs/editor/test/common/core/viewLineToken.ts b/src/vs/editor/test/common/core/viewLineToken.ts index 0492dfcc375..d3a8b8b8500 100644 --- a/src/vs/editor/test/common/core/viewLineToken.ts +++ b/src/vs/editor/test/common/core/viewLineToken.ts @@ -95,6 +95,11 @@ export class ViewLineTokens implements IViewLineTokens { public findTokenIndexAtOffset(offset: number): number { throw new Error('Not implemented'); } + + public getLineContent(): string { + throw new Error('Not implemented'); + } + } export class ViewLineTokenFactory {