From 635826ff131c0de5bbb948806ef408d459945e79 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 6 Jul 2016 11:44:51 -0700 Subject: [PATCH] Remove the unused text buffer from ScriptInfo --- src/server/editorServices.ts | 2 +- tests/cases/unittests/cachingInServerLSHost.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 092450e526c16..6a2beccc243c5 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -38,7 +38,7 @@ namespace ts.server { path: Path; scriptKind: ScriptKind; - constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) { + constructor(private host: ServerHost, public fileName: string, content: string, public isOpen = false) { this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.svc = ScriptVersionCache.fromString(host, content); } diff --git a/tests/cases/unittests/cachingInServerLSHost.ts b/tests/cases/unittests/cachingInServerLSHost.ts index 2608a082d6df6..9cd5e071b738c 100644 --- a/tests/cases/unittests/cachingInServerLSHost.ts +++ b/tests/cases/unittests/cachingInServerLSHost.ts @@ -108,6 +108,8 @@ namespace ts { let diags = project.compilerService.languageService.getSemanticDiagnostics(imported.name); assert.equal(diags.length, 1); + let content = rootScriptInfo.getText(); + const originalFileExists = serverHost.fileExists; { // patch fileExists to make sure that disk is not touched @@ -118,7 +120,8 @@ namespace ts { const newContent = `import {x} from "f1" var x: string = 1;`; - rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); + rootScriptInfo.editContent(0, content.length, newContent); + content = newContent; // trigger synchronization to make sure that import will be fetched from the cache diags = project.compilerService.languageService.getSemanticDiagnostics(imported.name); // ensure file has correct number of errors after edit @@ -135,7 +138,8 @@ namespace ts { return originalFileExists.call(serverHost, fileName); }; const newContent = `import {x} from "f2"`; - rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); + rootScriptInfo.editContent(0, content.length, newContent); + content = newContent; try { // trigger synchronization to make sure that LSHost will try to find 'f2' module on disk @@ -160,7 +164,8 @@ namespace ts { }; const newContent = `import {x} from "f1"`; - rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); + rootScriptInfo.editContent(0, content.length, newContent); + content = newContent; project.compilerService.languageService.getSemanticDiagnostics(imported.name); assert.isTrue(fileExistsCalled); @@ -205,7 +210,7 @@ namespace ts { }; const { project, rootScriptInfo } = createProject(root.name, serverHost); - + const content = rootScriptInfo.getText(); let diags = project.compilerService.languageService.getSemanticDiagnostics(root.name); assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called"); assert.isTrue(diags.length === 1, "one diagnostic expected"); @@ -214,7 +219,7 @@ namespace ts { // assert that import will success once file appear on disk fileMap[imported.name] = imported; fileExistsCalledForBar = false; - rootScriptInfo.editContent(0, rootScriptInfo.content.length, `import {y} from "bar"`); + rootScriptInfo.editContent(0, content.length, `import {y} from "bar"`); diags = project.compilerService.languageService.getSemanticDiagnostics(root.name); assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called");