Exposes and adopts IViewLineTokens.getLineContent

This commit is contained in:
Henning Dieterichs
2021-11-03 12:11:37 +01:00
parent 0e72666f28
commit eec6ed94de
3 changed files with 11 additions and 8 deletions
+5
View File
@@ -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 (
@@ -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<SingleLineInlineDecoration>();
@@ -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;
}
@@ -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 {