@@ -116,7 +116,7 @@ export interface ServerOptions {
116
116
readonly connectionToken ?: string ;
117
117
readonly cert ?: string ;
118
118
readonly certKey ?: string ;
119
- readonly folderUri ?: string ;
119
+ readonly openUri ?: string ;
120
120
readonly host ?: string ;
121
121
readonly password ?: string ;
122
122
readonly port ?: number ;
@@ -552,9 +552,9 @@ export class MainServer extends Server {
552
552
util . promisify ( fs . readFile ) ( filePath , "utf8" ) ,
553
553
this . getFirstValidPath ( [
554
554
{ path : parsedUrl . query . workspace , workspace : true } ,
555
- { path : parsedUrl . query . folder } ,
555
+ { path : parsedUrl . query . folder , workspace : false } ,
556
556
( await this . readSettings ( ) ) . lastVisited ,
557
- { path : this . options . folderUri }
557
+ { path : this . options . openUri }
558
558
] ) ,
559
559
this . servicesPromise ,
560
560
] ) ;
@@ -598,7 +598,9 @@ export class MainServer extends Server {
598
598
}
599
599
600
600
/**
601
- * Choose the first valid path.
601
+ * Choose the first valid path. If `workspace` is undefined then either a
602
+ * workspace or a directory are acceptable. Otherwise it must be a file if a
603
+ * workspace or a directory otherwise.
602
604
*/
603
605
private async getFirstValidPath ( startPaths : Array < StartPath | undefined > ) : Promise < { uri : URI , workspace ?: boolean } | undefined > {
604
606
const logger = this . services . get ( ILogService ) as ILogService ;
@@ -613,9 +615,8 @@ export class MainServer extends Server {
613
615
const uri = URI . file ( sanitizeFilePath ( paths [ j ] , cwd ) ) ;
614
616
try {
615
617
const stat = await util . promisify ( fs . stat ) ( uri . fsPath ) ;
616
- // Workspace must be a file.
617
- if ( ! ! startPath . workspace !== stat . isDirectory ( ) ) {
618
- return { uri, workspace : startPath . workspace } ;
618
+ if ( typeof startPath . workspace === "undefined" || startPath . workspace !== stat . isDirectory ( ) ) {
619
+ return { uri, workspace : ! stat . isDirectory ( ) } ;
619
620
}
620
621
} catch ( error ) {
621
622
logger . warn ( error . message ) ;
0 commit comments