@@ -22,7 +22,14 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
22
22
this . onDidChangeFile = this . _emitter . event ;
23
23
}
24
24
25
+ // Used by import and compile to make sure we notice its changes
25
26
public fireFileChanged ( uri : vscode . Uri ) : void {
27
+ // Remove entry from our cache
28
+ this . _lookupParentDirectory ( uri ) . then ( ( parent ) => {
29
+ const name = path . basename ( uri . path ) ;
30
+ parent . entries . delete ( name ) ;
31
+ } ) ;
32
+ // Queue the event
26
33
this . _fireSoon ( { type : vscode . FileChangeType . Changed , uri } ) ;
27
34
}
28
35
@@ -139,8 +146,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
139
146
return this . _lookupAsFile ( uri ) . then (
140
147
( ) => {
141
148
// Weirdly, if the file exists on the server we don't actually write its content here.
142
- // Instead we simply return as though we succeeded. The actual writing is done by our
143
- // workspace.onDidSaveTextDocument handler.
149
+ // Instead we simply return as though we wrote it successfully.
150
+ // The actual writing is done by our workspace.onDidSaveTextDocument handler.
144
151
return ;
145
152
} ,
146
153
( error ) => {
@@ -195,6 +202,11 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
195
202
if ( response . result . ext ) {
196
203
fireOtherStudioAction ( OtherStudioAction . DeletedDocument , uri , response . result . ext ) ;
197
204
}
205
+ // Remove entry from our cache
206
+ this . _lookupParentDirectory ( uri ) . then ( ( parent ) => {
207
+ const name = path . basename ( uri . path ) ;
208
+ parent . entries . delete ( name ) ;
209
+ } ) ;
198
210
this . _fireSoon ( { type : vscode . FileChangeType . Deleted , uri } ) ;
199
211
} ) ;
200
212
}
@@ -214,6 +226,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
214
226
} ) ;
215
227
}
216
228
229
+ // Fetch entry (a file or directory) from cache, else from server
217
230
private async _lookup ( uri : vscode . Uri ) : Promise < Entry > {
218
231
const parts = uri . path . split ( "/" ) ;
219
232
let entry : Entry = this . root ;
@@ -254,6 +267,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
254
267
throw vscode . FileSystemError . FileNotADirectory ( uri ) ;
255
268
}
256
269
270
+ // Fetch from server and cache it
257
271
private async _lookupAsFile ( uri : vscode . Uri ) : Promise < File > {
258
272
// Reject attempts to access files in .-folders such as .vscode and .git
259
273
if ( uri . path . match ( / \/ \. [ ^ / ] * \/ / ) ) {
@@ -282,6 +296,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
282
296
)
283
297
. then ( ( entry ) =>
284
298
this . _lookupParentDirectory ( uri ) . then ( ( parent ) => {
299
+ // Store in parent directory's cache
285
300
parent . entries . set ( name , entry ) ;
286
301
return entry ;
287
302
} )
0 commit comments