@@ -28,7 +28,7 @@ interface ServerSession {
28
28
}
29
29
30
30
interface VsRecents {
31
- [ key : string ] : ( string | object ) [ ]
31
+ [ key : string ] : ( string | { configURIPath : string } ) [ ]
32
32
}
33
33
34
34
type VsSettings = [ string , string ] [ ]
@@ -322,36 +322,42 @@ export class ApiHttpProvider extends HttpProvider {
322
322
throw new Error ( "settings appear malformed" )
323
323
}
324
324
325
- const paths : { [ key : string ] : Promise < string > } = { }
325
+ const pathPromises : { [ key : string ] : Promise < string > } = { }
326
+ const workspacePromises : { [ key : string ] : Promise < string > } = { }
326
327
Object . values ( JSON . parse ( setting [ 1 ] ) as VsRecents ) . forEach ( ( recents ) => {
327
- recents
328
- . filter ( ( recent ) => typeof recent === "string" )
329
- . forEach ( ( recent ) => {
330
- try {
331
- const pathname = url . parse ( recent as string ) . pathname
332
- if ( pathname && ! paths [ pathname ] ) {
333
- paths [ pathname ] = new Promise < string > ( ( resolve ) => {
334
- fs . stat ( pathname )
335
- . then ( ( ) => resolve ( pathname ) )
336
- . catch ( ( ) => resolve ( ) )
337
- } )
338
- }
339
- } catch ( error ) {
340
- logger . debug ( "invalid path" , field ( "path" , recent ) )
328
+ recents . forEach ( ( recent ) => {
329
+ try {
330
+ const target = typeof recent === "string" ? pathPromises : workspacePromises
331
+ const pathname = url . parse ( typeof recent === "string" ? recent : recent . configURIPath ) . pathname
332
+ if ( pathname && ! target [ pathname ] ) {
333
+ target [ pathname ] = new Promise < string > ( ( resolve ) => {
334
+ fs . stat ( pathname )
335
+ . then ( ( ) => resolve ( pathname ) )
336
+ . catch ( ( ) => resolve ( ) )
337
+ } )
341
338
}
342
- } )
339
+ } catch ( error ) {
340
+ logger . debug ( "invalid path" , field ( "path" , recent ) )
341
+ }
342
+ } )
343
343
} )
344
344
345
+ const [ paths , workspaces ] = await Promise . all ( [
346
+ Promise . all ( Object . values ( pathPromises ) ) ,
347
+ Promise . all ( Object . values ( workspacePromises ) ) ,
348
+ ] )
349
+
345
350
return {
346
- paths : await Promise . all ( Object . values ( paths ) ) ,
351
+ paths : paths . filter ( ( p ) => ! ! p ) ,
352
+ workspaces : workspaces . filter ( ( p ) => ! ! p ) ,
347
353
}
348
354
} catch ( error ) {
349
355
if ( error . code !== "ENOENT" ) {
350
356
throw error
351
357
}
352
358
}
353
359
354
- return { paths : [ ] }
360
+ return { paths : [ ] , workspaces : [ ] }
355
361
}
356
362
357
363
/**
0 commit comments