@@ -769,38 +769,42 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
769
769
}
770
770
771
771
private async doExtractPathsFromAPI ( openConfig : IOpenConfiguration ) : Promise < IPathToOpen [ ] > {
772
- const pathsToOpen : IPathToOpen [ ] = [ ] ;
773
- const pathResolveOptions : IPathResolveOptions = { gotoLineMode : openConfig . gotoLineMode , remoteAuthority : openConfig . remoteAuthority } ;
774
- for ( const pathToOpen of coalesce ( openConfig . urisToOpen || [ ] ) ) {
772
+ const pathResolveOptions : IPathResolveOptions = {
773
+ gotoLineMode : openConfig . gotoLineMode ,
774
+ remoteAuthority : openConfig . remoteAuthority
775
+ } ;
776
+
777
+ const pathsToOpen = await Promise . all ( coalesce ( openConfig . urisToOpen || [ ] ) . map ( async pathToOpen => {
775
778
const path = await this . resolveOpenable ( pathToOpen , pathResolveOptions ) ;
776
779
777
780
// Path exists
778
781
if ( path ) {
779
782
path . label = pathToOpen . label ;
780
- pathsToOpen . push ( path ) ;
783
+
784
+ return path ;
781
785
}
782
786
783
787
// Path does not exist: show a warning box
784
- else {
785
- const uri = this . resourceFromOpenable ( pathToOpen ) ;
786
-
787
- const options : MessageBoxOptions = {
788
- title : this . productService . nameLong ,
789
- type : 'info' ,
790
- buttons : [ mnemonicButtonLabel ( localize ( { key : 'ok' , comment : [ '&& denotes a mnemonic' ] } , "&&OK" ) ) ] ,
791
- defaultId : 0 ,
792
- message : uri . scheme === Schemas . file ? localize ( 'pathNotExistTitle' , "Path does not exist" ) : localize ( 'uriInvalidTitle' , "URI can not be opened" ) ,
793
- detail : uri . scheme === Schemas . file ?
794
- localize ( 'pathNotExistDetail' , "The path '{0}' does not exist on this computer." , getPathLabel ( uri , { os : OS , tildify : this . environmentMainService } ) ) :
795
- localize ( 'uriInvalidDetail' , "The URI '{0}' is not valid and can not be opened." , uri . toString ( true ) ) ,
796
- noLink : true
797
- } ;
788
+ const uri = this . resourceFromOpenable ( pathToOpen ) ;
789
+
790
+ const options : MessageBoxOptions = {
791
+ title : this . productService . nameLong ,
792
+ type : 'info' ,
793
+ buttons : [ mnemonicButtonLabel ( localize ( { key : 'ok' , comment : [ '&& denotes a mnemonic' ] } , "&&OK" ) ) ] ,
794
+ defaultId : 0 ,
795
+ message : uri . scheme === Schemas . file ? localize ( 'pathNotExistTitle' , "Path does not exist" ) : localize ( 'uriInvalidTitle' , "URI can not be opened" ) ,
796
+ detail : uri . scheme === Schemas . file ?
797
+ localize ( 'pathNotExistDetail' , "The path '{0}' does not exist on this computer." , getPathLabel ( uri , { os : OS , tildify : this . environmentMainService } ) ) :
798
+ localize ( 'uriInvalidDetail' , "The URI '{0}' is not valid and can not be opened." , uri . toString ( true ) ) ,
799
+ noLink : true
800
+ } ;
801
+
802
+ this . dialogMainService . showMessageBox ( options , withNullAsUndefined ( BrowserWindow . getFocusedWindow ( ) ) ) ;
798
803
799
- this . dialogMainService . showMessageBox ( options , withNullAsUndefined ( BrowserWindow . getFocusedWindow ( ) ) ) ;
800
- }
801
- }
804
+ return undefined ;
805
+ } ) ) ;
802
806
803
- return pathsToOpen ;
807
+ return coalesce ( pathsToOpen ) ;
804
808
}
805
809
806
810
private async doExtractPathsFromCLI ( cli : NativeParsedArgs ) : Promise < IPath [ ] > {
@@ -820,39 +824,39 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
820
824
// folder uris
821
825
const folderUris = cli [ 'folder-uri' ] ;
822
826
if ( folderUris ) {
823
- for ( const rawFolderUri of folderUris ) {
827
+ const resolvedFolderUris = await Promise . all ( folderUris . map ( rawFolderUri => {
824
828
const folderUri = this . cliArgToUri ( rawFolderUri ) ;
825
- if ( folderUri ) {
826
- const path = await this . resolveOpenable ( { folderUri } , pathResolveOptions ) ;
827
- if ( path ) {
828
- pathsToOpen . push ( path ) ;
829
- }
829
+ if ( ! folderUri ) {
830
+ return undefined ;
830
831
}
831
- }
832
+
833
+ return this . resolveOpenable ( { folderUri } , pathResolveOptions ) ;
834
+ } ) ) ;
835
+
836
+ pathsToOpen . push ( ...coalesce ( resolvedFolderUris ) ) ;
832
837
}
833
838
834
839
// file uris
835
840
const fileUris = cli [ 'file-uri' ] ;
836
841
if ( fileUris ) {
837
- for ( const rawFileUri of fileUris ) {
842
+ const resolvedFileUris = await Promise . all ( fileUris . map ( rawFileUri => {
838
843
const fileUri = this . cliArgToUri ( rawFileUri ) ;
839
- if ( fileUri ) {
840
- const path = await this . resolveOpenable ( hasWorkspaceFileExtension ( rawFileUri ) ? { workspaceUri : fileUri } : { fileUri } , pathResolveOptions ) ;
841
- if ( path ) {
842
- pathsToOpen . push ( path ) ;
843
- }
844
+ if ( ! fileUri ) {
845
+ return undefined ;
844
846
}
845
- }
847
+
848
+ return this . resolveOpenable ( hasWorkspaceFileExtension ( rawFileUri ) ? { workspaceUri : fileUri } : { fileUri } , pathResolveOptions ) ;
849
+ } ) ) ;
850
+
851
+ pathsToOpen . push ( ...coalesce ( resolvedFileUris ) ) ;
846
852
}
847
853
848
854
// folder or file paths
849
- const cliPaths = cli . _ ;
850
- for ( const cliPath of cliPaths ) {
851
- const path = pathResolveOptions . remoteAuthority ? this . doResolvePathRemote ( cliPath , pathResolveOptions ) : await this . doResolveFilePath ( cliPath , pathResolveOptions ) ;
852
- if ( path ) {
853
- pathsToOpen . push ( path ) ;
854
- }
855
- }
855
+ const resolvedCliPaths = await Promise . all ( cli . _ . map ( cliPath => {
856
+ return pathResolveOptions . remoteAuthority ? this . doResolveRemotePath ( cliPath , pathResolveOptions ) : this . doResolveFilePath ( cliPath , pathResolveOptions ) ;
857
+ } ) ) ;
858
+
859
+ pathsToOpen . push ( ...coalesce ( resolvedCliPaths ) ) ;
856
860
857
861
return pathsToOpen ;
858
862
}
@@ -900,32 +904,33 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
900
904
lastSessionWindows . push ( this . windowsStateHandler . state . lastActiveWindow ) ;
901
905
}
902
906
903
- const pathsToOpen : IPathToOpen [ ] = [ ] ;
904
- for ( const lastSessionWindow of lastSessionWindows ) {
907
+ const pathsToOpen = await Promise . all ( lastSessionWindows . map ( async lastSessionWindow => {
905
908
906
909
// Workspaces
907
910
if ( lastSessionWindow . workspace ) {
908
911
const pathToOpen = await this . resolveOpenable ( { workspaceUri : lastSessionWindow . workspace . configPath } , { remoteAuthority : lastSessionWindow . remoteAuthority , rejectTransientWorkspaces : true /* https://github.com/microsoft/vscode/issues/119695 */ } ) ;
909
912
if ( isWorkspacePathToOpen ( pathToOpen ) ) {
910
- pathsToOpen . push ( pathToOpen ) ;
913
+ return pathToOpen ;
911
914
}
912
915
}
913
916
914
917
// Folders
915
918
else if ( lastSessionWindow . folderUri ) {
916
919
const pathToOpen = await this . resolveOpenable ( { folderUri : lastSessionWindow . folderUri } , { remoteAuthority : lastSessionWindow . remoteAuthority } ) ;
917
920
if ( isSingleFolderWorkspacePathToOpen ( pathToOpen ) ) {
918
- pathsToOpen . push ( pathToOpen ) ;
921
+ return pathToOpen ;
919
922
}
920
923
}
921
924
922
925
// Empty window, potentially editors open to be restored
923
926
else if ( restoreWindowsSetting !== 'folders' && lastSessionWindow . backupPath ) {
924
- pathsToOpen . push ( { backupPath : lastSessionWindow . backupPath , remoteAuthority : lastSessionWindow . remoteAuthority } ) ;
927
+ return { backupPath : lastSessionWindow . backupPath , remoteAuthority : lastSessionWindow . remoteAuthority } ;
925
928
}
926
- }
927
929
928
- return pathsToOpen ;
930
+ return undefined ;
931
+ } ) ) ;
932
+
933
+ return coalesce ( pathsToOpen ) ;
929
934
}
930
935
}
931
936
}
@@ -1097,7 +1102,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
1097
1102
return undefined ;
1098
1103
}
1099
1104
1100
- private doResolvePathRemote ( path : string , options : IPathResolveOptions ) : IPathToOpen < ITextEditorOptions > | undefined {
1105
+ private doResolveRemotePath ( path : string , options : IPathResolveOptions ) : IPathToOpen < ITextEditorOptions > | undefined {
1101
1106
const first = path . charCodeAt ( 0 ) ;
1102
1107
const remoteAuthority = options . remoteAuthority ;
1103
1108
0 commit comments