allow to compute change ranges only for snapshots from the same script version cache

This commit is contained in:
Vladimir Matveev
2016-12-14 14:43:45 -08:00
parent 8e94d84953
commit dda24f6d70
2 changed files with 28 additions and 3 deletions

View File

@@ -398,7 +398,7 @@ namespace ts.server {
index: LineIndex;
changesSincePreviousVersion: TextChange[] = [];
constructor(public version: number, public cache: ScriptVersionCache) {
constructor(readonly version: number, readonly cache: ScriptVersionCache) {
}
getText(rangeStart: number, rangeEnd: number) {
@@ -438,7 +438,7 @@ namespace ts.server {
}
}
getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange {
if (oldSnapshot instanceof LineIndexSnapshot) {
if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) {
return this.getTextChangeRangeSinceVersion(oldSnapshot.version);
}
}