Skip to content

Commit 9d721c5

Browse files
committed
fix intersystems-community#879 regression that broke server-side editing from ObjectScript Explorer
1 parent 05f43ba commit 9d721c5

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
183183
public async readFile(uri: vscode.Uri): Promise<Uint8Array> {
184184
// Use _lookup() instead of _lookupAsFile() so we send
185185
// our cached mtime with the GET /doc request if we have it
186-
return this._lookup(uri).then((file: File) => {
186+
return this._lookup(uri, true).then((file: File) => {
187187
// Update cache entry
188188
const uniqueId = `${workspaceFolderOfUri(uri)}:${file.fileName}`;
189189
workspaceState.update(`${uniqueId}:mtime`, file.mtime);
@@ -336,7 +336,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
336336
}
337337

338338
// Fetch entry (a file or directory) from cache, else from server
339-
private async _lookup(uri: vscode.Uri): Promise<Entry> {
339+
private async _lookup(uri: vscode.Uri, fillInPath?: boolean): Promise<Entry> {
340340
const api = new AtelierAPI(uri);
341341
if (uri.path === "/") {
342342
await api
@@ -363,9 +363,16 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
363363
if (entry instanceof Directory) {
364364
child = entry.entries.get(part);
365365
// If the last element of path is dotted and is one we haven't already cached as a directory
366-
// then it is assumed to be a file.
366+
// then it is assumed to be a file. Treat all other cases as a directory we haven't yet explored.
367367
if (!child && (!part.includes(".") || i + 1 < parts.length)) {
368-
throw vscode.FileSystemError.FileNotFound(uri);
368+
if (!fillInPath) {
369+
throw vscode.FileSystemError.FileNotFound(uri);
370+
}
371+
// Caller granted us permission to create structures for intermediate directories not yet seen.
372+
// This arises when ObjectScript Explorer uses isfs to enable server-side editing. See https://github.com/intersystems-community/vscode-objectscript/issues/879
373+
const fullName = entry.name === "" ? part : entry.fullName + "/" + part;
374+
child = new Directory(part, fullName);
375+
entry.entries.set(part, child);
369376
}
370377
}
371378
if (!child) {
@@ -389,7 +396,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
389396
if (uri.path.startsWith("/node_modules")) {
390397
throw vscode.FileSystemError.FileNotADirectory(uri);
391398
}
392-
const entry = await this._lookup(uri);
399+
const entry = await this._lookup(uri, true);
393400
if (entry instanceof Directory) {
394401
return entry;
395402
}

0 commit comments

Comments
 (0)