Skip to content

Commit b0c81f4

Browse files
committed
1 parent 80b0d7f commit b0c81f4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/vs/editor/common/model/mirrorTextModel.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ export class MirrorTextModel {
3131
protected _eol: string;
3232
protected _versionId: number;
3333
protected _lineStarts: PrefixSumComputer | null;
34+
private _cachedTextValue: string | null;
3435

3536
constructor(uri: URI, lines: string[], eol: string, versionId: number) {
3637
this._uri = uri;
3738
this._lines = lines;
3839
this._eol = eol;
3940
this._versionId = versionId;
4041
this._lineStarts = null;
42+
this._cachedTextValue = null;
4143
}
4244

4345
dispose(): void {
@@ -49,7 +51,10 @@ export class MirrorTextModel {
4951
}
5052

5153
getText(): string {
52-
return this._lines.join(this._eol);
54+
if (this._cachedTextValue === null) {
55+
this._cachedTextValue = this._lines.join(this._eol);
56+
}
57+
return this._cachedTextValue;
5358
}
5459

5560
onEvents(e: IModelChangedEvent): void {
@@ -66,6 +71,7 @@ export class MirrorTextModel {
6671
}
6772

6873
this._versionId = e.versionId;
74+
this._cachedTextValue = null;
6975
}
7076

7177
protected _ensureLineStarts(): void {

0 commit comments

Comments
 (0)