diff --git a/src/server/project.ts b/src/server/project.ts index 92f1d097b3..9a4e7ada96 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -267,15 +267,6 @@ namespace ts.server { } } - saveTo(filename: NormalizedPath, tmpfilename: NormalizedPath) { - const script = this.projectService.getScriptInfoForNormalizedPath(filename); - if (script) { - Debug.assert(script.isAttached(this)); - const snap = script.snap(); - this.projectService.host.writeFile(tmpfilename, snap.getText(0, snap.getLength())); - } - } - reloadScript(filename: NormalizedPath): boolean { const script = this.projectService.getScriptInfoForNormalizedPath(filename); if (script) { diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 7ab6bc7e7e..901e247df6 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -110,6 +110,11 @@ namespace ts.server { this.markContainingProjectsAsDirty(); } + saveTo(fileName: string) { + const snap = this.snap(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); + } + reloadFromFile() { this.svc.reloadFromFile(this.fileName); this.markContainingProjectsAsDirty(); diff --git a/src/server/session.ts b/src/server/session.ts index 88676aae6a..739446b18c 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1015,12 +1015,9 @@ namespace ts.server { } private saveToTmp(fileName: string, tempFileName: string) { - const file = toNormalizedPath(fileName); - const tmpfile = toNormalizedPath(tempFileName); - - const project = this.projectService.getDefaultProjectForFile(file); - if (project) { - project.saveTo(file, tmpfile); + const scriptInfo = this.projectService.getScriptInfo(fileName); + if (scriptInfo) { + scriptInfo.saveTo(tempFileName); } }