@@ -108,6 +108,8 @@ namespace ts {
108108 let diags = project . compilerService . languageService . getSemanticDiagnostics ( imported . name ) ;
109109 assert . equal ( diags . length , 1 ) ;
110110
111+ let content = rootScriptInfo . getText ( ) ;
112+
111113 const originalFileExists = serverHost . fileExists ;
112114 {
113115 // patch fileExists to make sure that disk is not touched
@@ -118,7 +120,8 @@ namespace ts {
118120
119121 const newContent = `import {x} from "f1"
120122 var x: string = 1;` ;
121- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , newContent ) ;
123+ rootScriptInfo . editContent ( 0 , content . length , newContent ) ;
124+ content = newContent ;
122125 // trigger synchronization to make sure that import will be fetched from the cache
123126 diags = project . compilerService . languageService . getSemanticDiagnostics ( imported . name ) ;
124127 // ensure file has correct number of errors after edit
@@ -135,7 +138,8 @@ namespace ts {
135138 return originalFileExists . call ( serverHost , fileName ) ;
136139 } ;
137140 const newContent = `import {x} from "f2"` ;
138- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , newContent ) ;
141+ rootScriptInfo . editContent ( 0 , content . length , newContent ) ;
142+ content = newContent ;
139143
140144 try {
141145 // trigger synchronization to make sure that LSHost will try to find 'f2' module on disk
@@ -160,7 +164,8 @@ namespace ts {
160164 } ;
161165
162166 const newContent = `import {x} from "f1"` ;
163- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , newContent ) ;
167+ rootScriptInfo . editContent ( 0 , content . length , newContent ) ;
168+ content = newContent ;
164169 project . compilerService . languageService . getSemanticDiagnostics ( imported . name ) ;
165170 assert . isTrue ( fileExistsCalled ) ;
166171
@@ -205,7 +210,7 @@ namespace ts {
205210 } ;
206211
207212 const { project, rootScriptInfo } = createProject ( root . name , serverHost ) ;
208-
213+ const content = rootScriptInfo . getText ( ) ;
209214 let diags = project . compilerService . languageService . getSemanticDiagnostics ( root . name ) ;
210215 assert . isTrue ( fileExistsCalledForBar , "'fileExists' should be called" ) ;
211216 assert . isTrue ( diags . length === 1 , "one diagnostic expected" ) ;
@@ -214,7 +219,7 @@ namespace ts {
214219 // assert that import will success once file appear on disk
215220 fileMap [ imported . name ] = imported ;
216221 fileExistsCalledForBar = false ;
217- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , `import {y} from "bar"` ) ;
222+ rootScriptInfo . editContent ( 0 , content . length , `import {y} from "bar"` ) ;
218223
219224 diags = project . compilerService . languageService . getSemanticDiagnostics ( root . name ) ;
220225 assert . isTrue ( fileExistsCalledForBar , "'fileExists' should be called" ) ;
0 commit comments