Skip to content

Commit 73058ef

Browse files
committed
fix #303 flush isfs cache on import and compile
1 parent abfd788 commit 73058ef

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
2222
this.onDidChangeFile = this._emitter.event;
2323
}
2424

25+
// Used by import and compile to make sure we notice its changes
2526
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
2633
this._fireSoon({ type: vscode.FileChangeType.Changed, uri });
2734
}
2835

@@ -139,8 +146,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
139146
return this._lookupAsFile(uri).then(
140147
() => {
141148
// 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.
144151
return;
145152
},
146153
(error) => {
@@ -195,6 +202,11 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
195202
if (response.result.ext) {
196203
fireOtherStudioAction(OtherStudioAction.DeletedDocument, uri, response.result.ext);
197204
}
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+
});
198210
this._fireSoon({ type: vscode.FileChangeType.Deleted, uri });
199211
});
200212
}
@@ -214,6 +226,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
214226
});
215227
}
216228

229+
// Fetch entry (a file or directory) from cache, else from server
217230
private async _lookup(uri: vscode.Uri): Promise<Entry> {
218231
const parts = uri.path.split("/");
219232
let entry: Entry = this.root;
@@ -254,6 +267,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
254267
throw vscode.FileSystemError.FileNotADirectory(uri);
255268
}
256269

270+
// Fetch from server and cache it
257271
private async _lookupAsFile(uri: vscode.Uri): Promise<File> {
258272
// Reject attempts to access files in .-folders such as .vscode and .git
259273
if (uri.path.match(/\/\.[^/]*\//)) {
@@ -282,6 +296,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
282296
)
283297
.then((entry) =>
284298
this._lookupParentDirectory(uri).then((parent) => {
299+
// Store in parent directory's cache
285300
parent.entries.set(name, entry);
286301
return entry;
287302
})

0 commit comments

Comments
 (0)