@@ -183,7 +183,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
183
183
public async readFile ( uri : vscode . Uri ) : Promise < Uint8Array > {
184
184
// Use _lookup() instead of _lookupAsFile() so we send
185
185
// 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 ) => {
187
187
// Update cache entry
188
188
const uniqueId = `${ workspaceFolderOfUri ( uri ) } :${ file . fileName } ` ;
189
189
workspaceState . update ( `${ uniqueId } :mtime` , file . mtime ) ;
@@ -336,7 +336,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
336
336
}
337
337
338
338
// 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 > {
340
340
const api = new AtelierAPI ( uri ) ;
341
341
if ( uri . path === "/" ) {
342
342
await api
@@ -363,9 +363,18 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
363
363
if ( entry instanceof Directory ) {
364
364
child = entry . entries . get ( part ) ;
365
365
// 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.
367
367
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, and when reloading a workspace
373
+ // in which isfs documents were previously open.
374
+ // See https://github.com/intersystems-community/vscode-objectscript/issues/879
375
+ const fullName = entry . name === "" ? part : entry . fullName + "/" + part ;
376
+ child = new Directory ( part , fullName ) ;
377
+ entry . entries . set ( part , child ) ;
369
378
}
370
379
}
371
380
if ( ! child ) {
@@ -389,7 +398,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
389
398
if ( uri . path . startsWith ( "/node_modules" ) ) {
390
399
throw vscode . FileSystemError . FileNotADirectory ( uri ) ;
391
400
}
392
- const entry = await this . _lookup ( uri ) ;
401
+ const entry = await this . _lookup ( uri , true ) ;
393
402
if ( entry instanceof Directory ) {
394
403
return entry ;
395
404
}
0 commit comments