@@ -108,6 +108,8 @@ namespace ts {
108
108
let diags = project . compilerService . languageService . getSemanticDiagnostics ( imported . name ) ;
109
109
assert . equal ( diags . length , 1 ) ;
110
110
111
+ let content = rootScriptInfo . getText ( ) ;
112
+
111
113
const originalFileExists = serverHost . fileExists ;
112
114
{
113
115
// patch fileExists to make sure that disk is not touched
@@ -118,7 +120,8 @@ namespace ts {
118
120
119
121
const newContent = `import {x} from "f1"
120
122
var x: string = 1;` ;
121
- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , newContent ) ;
123
+ rootScriptInfo . editContent ( 0 , content . length , newContent ) ;
124
+ content = newContent ;
122
125
// trigger synchronization to make sure that import will be fetched from the cache
123
126
diags = project . compilerService . languageService . getSemanticDiagnostics ( imported . name ) ;
124
127
// ensure file has correct number of errors after edit
@@ -135,7 +138,8 @@ namespace ts {
135
138
return originalFileExists . call ( serverHost , fileName ) ;
136
139
} ;
137
140
const newContent = `import {x} from "f2"` ;
138
- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , newContent ) ;
141
+ rootScriptInfo . editContent ( 0 , content . length , newContent ) ;
142
+ content = newContent ;
139
143
140
144
try {
141
145
// trigger synchronization to make sure that LSHost will try to find 'f2' module on disk
@@ -160,7 +164,8 @@ namespace ts {
160
164
} ;
161
165
162
166
const newContent = `import {x} from "f1"` ;
163
- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , newContent ) ;
167
+ rootScriptInfo . editContent ( 0 , content . length , newContent ) ;
168
+ content = newContent ;
164
169
project . compilerService . languageService . getSemanticDiagnostics ( imported . name ) ;
165
170
assert . isTrue ( fileExistsCalled ) ;
166
171
@@ -205,7 +210,7 @@ namespace ts {
205
210
} ;
206
211
207
212
const { project, rootScriptInfo } = createProject ( root . name , serverHost ) ;
208
-
213
+ const content = rootScriptInfo . getText ( ) ;
209
214
let diags = project . compilerService . languageService . getSemanticDiagnostics ( root . name ) ;
210
215
assert . isTrue ( fileExistsCalledForBar , "'fileExists' should be called" ) ;
211
216
assert . isTrue ( diags . length === 1 , "one diagnostic expected" ) ;
@@ -214,7 +219,7 @@ namespace ts {
214
219
// assert that import will success once file appear on disk
215
220
fileMap [ imported . name ] = imported ;
216
221
fileExistsCalledForBar = false ;
217
- rootScriptInfo . editContent ( 0 , rootScriptInfo . content . length , `import {y} from "bar"` ) ;
222
+ rootScriptInfo . editContent ( 0 , content . length , `import {y} from "bar"` ) ;
218
223
219
224
diags = project . compilerService . languageService . getSemanticDiagnostics ( root . name ) ;
220
225
assert . isTrue ( fileExistsCalledForBar , "'fileExists' should be called" ) ;
0 commit comments