@@ -261,6 +261,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
261
261
} ;
262
262
} ) ;
263
263
264
+
264
265
const program = service . getProgram ( ) ;
265
266
program . getSourceFiles ( ) . forEach ( file => {
266
267
files [ file . fileName ] = {
@@ -270,6 +271,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
270
271
} ;
271
272
} ) ;
272
273
274
+
273
275
if ( loaderConfig . debug ) {
274
276
console . log ( `[${ instanceName } ] @DEBUG Initial files` , Object . keys ( files ) ) ;
275
277
}
@@ -280,19 +282,18 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
280
282
} ) ;
281
283
}
282
284
283
-
284
285
replyOk ( seq , null ) ;
285
286
}
286
287
287
- function updateFile ( fileName : string , text : string ) {
288
+ function updateFile ( fileName : string , text : string , ifExist = false ) {
288
289
const file = files [ fileName ] ;
289
290
if ( file ) {
290
291
if ( file . text === text ) { return ; }
291
292
projectVersion ++ ;
292
293
file . version ++ ;
293
294
file . text = text ;
294
295
file . snapshot = compiler . ScriptSnapshot . fromString ( text ) ;
295
- } else {
296
+ } else if ( ! ifExist ) {
296
297
projectVersion ++ ;
297
298
files [ fileName ] = {
298
299
text,
@@ -337,7 +338,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
337
338
}
338
339
339
340
function processUpdate ( { seq, payload} : UpdateFile . Request ) {
340
- updateFile ( payload . fileName , payload . text ) ;
341
+ updateFile ( payload . fileName , payload . text , payload . ifExist ) ;
341
342
replyOk ( seq , null ) ;
342
343
}
343
344
@@ -407,8 +408,12 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
407
408
. filter ( diag => ! ignoreDiagnostics [ diag . code ] )
408
409
. map ( diagnostic => {
409
410
const message = compiler . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
410
- const fileName = diagnostic . file && './' + path . relative ( context , diagnostic . file . fileName ) ;
411
-
411
+ let fileName = diagnostic . file && path . relative ( context , diagnostic . file . fileName ) ;
412
+
413
+ if ( fileName [ 0 ] !== '.' ) {
414
+ fileName = './' + fileName ;
415
+ }
416
+
412
417
let pretty = '' ;
413
418
let line = 0 ;
414
419
let character = 0 ;
0 commit comments