fix(language-service): use script versions for incremental compilations (#41475)

This commit has the Language Service take advantage of versioned source
files added in the compiler previously. With this change, the Language
Service's incremental compilations will now be correct even if the TS
Language service mutates `ts.SourceFile`s without changing their object
identity, as we know it does in certain corner cases.

No test is added here as it is difficult to reproduce this behavior in the
LS's artificial testing environment. A test for this case exists in the
LS extension repo, where it will be used to validate that a workaround three
is no longer necessary.

PR Close #41475
This commit is contained in:
Alex Rickabaugh 2021-04-07 11:38:47 -04:00 committed by Zach Arend
parent dee95994b8
commit 78236bfdca
1 changed files with 3 additions and 0 deletions

View File

@ -487,6 +487,9 @@ function createProgramDriver(project: ts.server.Project): ProgramDriver {
scriptInfo.editContent(0, length, newText);
}
},
getSourceFileVersion(sf: ts.SourceFile): string {
return project.getScriptVersion(sf.fileName);
}
};
}