@@ -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,18 @@ 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, 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 ) ;
369378 }
370379 }
371380 if ( ! child ) {
@@ -389,7 +398,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
389398 if ( uri . path . startsWith ( "/node_modules" ) ) {
390399 throw vscode . FileSystemError . FileNotADirectory ( uri ) ;
391400 }
392- const entry = await this . _lookup ( uri ) ;
401+ const entry = await this . _lookup ( uri , true ) ;
393402 if ( entry instanceof Directory ) {
394403 return entry ;
395404 }
0 commit comments