提交 b0c81f44 编写于 作者: J Johannes Rieken
上级 80b0d7f0
......@@ -31,6 +31,7 @@ export class MirrorTextModel {
protected _eol: string;
protected _versionId: number;
protected _lineStarts: PrefixSumComputer | null;
private _cachedTextValue: string | null;
constructor(uri: URI, lines: string[], eol: string, versionId: number) {
this._uri = uri;
......@@ -38,6 +39,7 @@ export class MirrorTextModel {
this._eol = eol;
this._versionId = versionId;
this._lineStarts = null;
this._cachedTextValue = null;
}
dispose(): void {
......@@ -49,7 +51,10 @@ export class MirrorTextModel {
}
getText(): string {
return this._lines.join(this._eol);
if (this._cachedTextValue === null) {
this._cachedTextValue = this._lines.join(this._eol);
}
return this._cachedTextValue;
}
onEvents(e: IModelChangedEvent): void {
......@@ -66,6 +71,7 @@ export class MirrorTextModel {
}
this._versionId = e.versionId;
this._cachedTextValue = null;
}
protected _ensureLineStarts(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册