Skip to content

Commit 37c6f69

Browse files
author
steveluc
committed
Hold at most 4 snapshots per file in the server. This is about 1K per file.
1 parent 04320e4 commit 37c6f69

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/server/editorServices.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ module ts.server {
10731073

10741074
static changeNumberThreshold = 8;
10751075
static changeLengthThreshold = 256;
1076+
static maxVersions = 8;
10761077

10771078
// REVIEW: can optimize by coalescing simple edits
10781079
edit(pos: number, deleteLen: number, insertedText?: string) {
@@ -1133,6 +1134,13 @@ module ts.server {
11331134
this.currentVersion = snap.version;
11341135
this.versions[snap.version] = snap;
11351136
this.changes = [];
1137+
if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) {
1138+
var oldMin = this.minVersion;
1139+
this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1;
1140+
for (var j = oldMin; j < this.minVersion; j++) {
1141+
this.versions[j] = undefined;
1142+
}
1143+
}
11361144
}
11371145
return snap;
11381146
}

0 commit comments

Comments
 (0)