@@ -116,7 +116,7 @@ export interface ServerOptions {
116116 readonly connectionToken ?: string ;
117117 readonly cert ?: string ;
118118 readonly certKey ?: string ;
119- readonly folderUri ?: string ;
119+ readonly openUri ?: string ;
120120 readonly host ?: string ;
121121 readonly password ?: string ;
122122 readonly port ?: number ;
@@ -552,9 +552,9 @@ export class MainServer extends Server {
552552 util . promisify ( fs . readFile ) ( filePath , "utf8" ) ,
553553 this . getFirstValidPath ( [
554554 { path : parsedUrl . query . workspace , workspace : true } ,
555- { path : parsedUrl . query . folder } ,
555+ { path : parsedUrl . query . folder , workspace : false } ,
556556 ( await this . readSettings ( ) ) . lastVisited ,
557- { path : this . options . folderUri }
557+ { path : this . options . openUri }
558558 ] ) ,
559559 this . servicesPromise ,
560560 ] ) ;
@@ -598,7 +598,9 @@ export class MainServer extends Server {
598598 }
599599
600600 /**
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.
602604 */
603605 private async getFirstValidPath ( startPaths : Array < StartPath | undefined > ) : Promise < { uri : URI , workspace ?: boolean } | undefined > {
604606 const logger = this . services . get ( ILogService ) as ILogService ;
@@ -613,9 +615,8 @@ export class MainServer extends Server {
613615 const uri = URI . file ( sanitizeFilePath ( paths [ j ] , cwd ) ) ;
614616 try {
615617 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 ( ) } ;
619620 }
620621 } catch ( error ) {
621622 logger . warn ( error . message ) ;
0 commit comments