@@ -91,8 +91,7 @@ interface IPathParseOptions {
9191}
9292
9393interface IFileInputs {
94- filesToOpen : IPath [ ] ;
95- filesToCreate : IPath [ ] ;
94+ filesToOpenOrCreate : IPath [ ] ;
9695 filesToDiff : IPath [ ] ;
9796 filesToWait ?: IPathsToWaitFor ;
9897 remoteAuthority ?: string ;
@@ -112,9 +111,6 @@ interface IPathToOpen extends IPath {
112111 // the remote authority for the Code instance to open. Undefined if not remote.
113112 remoteAuthority ?: string ;
114113
115- // indicator to create the file path in the Code instance
116- createFilePath ?: boolean ;
117-
118114 // optional label for the recent history
119115 label ?: string ;
120116}
@@ -397,13 +393,9 @@ export class WindowsManager implements IWindowsMainService {
397393 workspacesToOpen . push ( path ) ;
398394 } else if ( path . fileUri ) {
399395 if ( ! fileInputs ) {
400- fileInputs = { filesToCreate : [ ] , filesToOpen : [ ] , filesToDiff : [ ] , remoteAuthority : path . remoteAuthority } ;
401- }
402- if ( ! path . createFilePath ) {
403- fileInputs . filesToOpen . push ( path ) ;
404- } else {
405- fileInputs . filesToCreate . push ( path ) ;
396+ fileInputs = { filesToOpenOrCreate : [ ] , filesToDiff : [ ] , remoteAuthority : path . remoteAuthority } ;
406397 }
398+ fileInputs . filesToOpenOrCreate . push ( path ) ;
407399 } else if ( path . backupPath ) {
408400 emptyToRestore . push ( { backupFolder : basename ( path . backupPath ) , remoteAuthority : path . remoteAuthority } ) ;
409401 } else {
@@ -413,15 +405,14 @@ export class WindowsManager implements IWindowsMainService {
413405
414406 // When run with --diff, take the files to open as files to diff
415407 // if there are exactly two files provided.
416- if ( fileInputs && openConfig . diffMode && fileInputs . filesToOpen . length === 2 ) {
417- fileInputs . filesToDiff = fileInputs . filesToOpen ;
418- fileInputs . filesToOpen = [ ] ;
419- fileInputs . filesToCreate = [ ] ; // diff ignores other files that do not exist
408+ if ( fileInputs && openConfig . diffMode && fileInputs . filesToOpenOrCreate . length === 2 ) {
409+ fileInputs . filesToDiff = fileInputs . filesToOpenOrCreate ;
410+ fileInputs . filesToOpenOrCreate = [ ] ;
420411 }
421412
422413 // When run with --wait, make sure we keep the paths to wait for
423414 if ( fileInputs && openConfig . waitMarkerFileURI ) {
424- fileInputs . filesToWait = { paths : [ ...fileInputs . filesToDiff , ...fileInputs . filesToOpen , ... fileInputs . filesToCreate ] , waitMarkerFileUri : openConfig . waitMarkerFileURI } ;
415+ fileInputs . filesToWait = { paths : [ ...fileInputs . filesToDiff , ...fileInputs . filesToOpenOrCreate ] , waitMarkerFileUri : openConfig . waitMarkerFileURI } ;
425416 }
426417
427418 //
@@ -551,7 +542,7 @@ export class WindowsManager implements IWindowsMainService {
551542 if ( potentialWindowsCount === 0 && fileInputs ) {
552543
553544 // Find suitable window or folder path to open files in
554- const fileToCheck = fileInputs . filesToOpen [ 0 ] || fileInputs . filesToCreate [ 0 ] || fileInputs . filesToDiff [ 0 ] ;
545+ const fileToCheck = fileInputs . filesToOpenOrCreate [ 0 ] || fileInputs . filesToDiff [ 0 ] ;
555546 // only look at the windows with correct authority
556547 const windows = WindowsManager . WINDOWS . filter ( w => w . remoteAuthority === fileInputs ! . remoteAuthority ) ;
557548
@@ -746,10 +737,9 @@ export class WindowsManager implements IWindowsMainService {
746737 private doOpenFilesInExistingWindow ( configuration : IOpenConfiguration , window : ICodeWindow , fileInputs ?: IFileInputs ) : ICodeWindow {
747738 window . focus ( ) ; // make sure window has focus
748739
749- const params : { filesToOpen ?: IPath [ ] , filesToCreate ?: IPath [ ] , filesToDiff ?: IPath [ ] , filesToWait ?: IPathsToWaitFor , termProgram ?: string } = { } ;
740+ const params : { filesToOpenOrCreate ?: IPath [ ] , filesToDiff ?: IPath [ ] , filesToWait ?: IPathsToWaitFor , termProgram ?: string } = { } ;
750741 if ( fileInputs ) {
751- params . filesToOpen = fileInputs . filesToOpen ;
752- params . filesToCreate = fileInputs . filesToCreate ;
742+ params . filesToOpenOrCreate = fileInputs . filesToOpenOrCreate ;
753743 params . filesToDiff = fileInputs . filesToDiff ;
754744 params . filesToWait = fileInputs . filesToWait ;
755745 }
@@ -1065,47 +1055,57 @@ export class WindowsManager implements IWindowsMainService {
10651055 anyPath = parsedPath . path ;
10661056 }
10671057
1068- // open remote if either specified in the cli even if it is a local file. TODO: Future idea: resolve in remote host context.
1058+ // open remote if either specified in the cli even if it is a local file. TODO@aeschli : Future idea: resolve in remote host context.
10691059 const remoteAuthority = options . remoteAuthority ;
10701060
10711061 const candidate = normalize ( anyPath ) ;
10721062 try {
10731063 const candidateStat = fs . statSync ( candidate ) ;
1074- if ( candidateStat ) {
1075- if ( candidateStat . isFile ( ) ) {
1076-
1077- // Workspace (unless disabled via flag)
1078- if ( ! forceOpenWorkspaceAsFile ) {
1079- const workspace = this . workspacesMainService . resolveLocalWorkspaceSync ( URI . file ( candidate ) ) ;
1080- if ( workspace ) {
1081- return { workspace : { id : workspace . id , configPath : workspace . configPath } , remoteAuthority : workspace . remoteAuthority } ;
1082- }
1064+ if ( candidateStat . isFile ( ) ) {
1065+
1066+ // Workspace (unless disabled via flag)
1067+ if ( ! forceOpenWorkspaceAsFile ) {
1068+ const workspace = this . workspacesMainService . resolveLocalWorkspaceSync ( URI . file ( candidate ) ) ;
1069+ if ( workspace ) {
1070+ return {
1071+ workspace : { id : workspace . id , configPath : workspace . configPath } ,
1072+ remoteAuthority : workspace . remoteAuthority ,
1073+ exists : true
1074+ } ;
10831075 }
1084-
1085- // File
1086- return {
1087- fileUri : URI . file ( candidate ) ,
1088- lineNumber,
1089- columnNumber,
1090- remoteAuthority
1091- } ;
10921076 }
10931077
1094- // Folder (we check for isDirectory() because e.g. paths like /dev/null
1095- // are neither file nor folder but some external tools might pass them
1096- // over to us)
1097- else if ( candidateStat . isDirectory ( ) ) {
1098- return {
1099- folderUri : URI . file ( candidate ) ,
1100- remoteAuthority
1101- } ;
1102- }
1078+ // File
1079+ return {
1080+ fileUri : URI . file ( candidate ) ,
1081+ lineNumber,
1082+ columnNumber,
1083+ remoteAuthority,
1084+ exists : true
1085+ } ;
1086+ }
1087+
1088+ // Folder (we check for isDirectory() because e.g. paths like /dev/null
1089+ // are neither file nor folder but some external tools might pass them
1090+ // over to us)
1091+ else if ( candidateStat . isDirectory ( ) ) {
1092+ return {
1093+ folderUri : URI . file ( candidate ) ,
1094+ remoteAuthority,
1095+ exists : true
1096+ } ;
11031097 }
11041098 } catch ( error ) {
11051099 const fileUri = URI . file ( candidate ) ;
11061100 this . historyMainService . removeFromRecentlyOpened ( [ fileUri ] ) ; // since file does not seem to exist anymore, remove from recent
1101+
1102+ // assume this is a file that does not yet exist
11071103 if ( options && options . ignoreFileNotFound ) {
1108- return { fileUri, createFilePath : true , remoteAuthority } ; // assume this is a file that does not yet exist
1104+ return {
1105+ fileUri,
1106+ remoteAuthority,
1107+ exists : false
1108+ } ;
11091109 }
11101110 }
11111111
@@ -1279,8 +1279,7 @@ export class WindowsManager implements IWindowsMainService {
12791279
12801280 const fileInputs = options . fileInputs ;
12811281 if ( fileInputs ) {
1282- configuration . filesToOpen = fileInputs . filesToOpen ;
1283- configuration . filesToCreate = fileInputs . filesToCreate ;
1282+ configuration . filesToOpenOrCreate = fileInputs . filesToOpenOrCreate ;
12841283 configuration . filesToDiff = fileInputs . filesToDiff ;
12851284 configuration . filesToWait = fileInputs . filesToWait ;
12861285 }
0 commit comments