File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,8 @@ code-server tries the following in order:
139139
1401401 . The ` workspace ` query parameter.
1411412 . The ` folder ` query parameter.
142- 3 . The directory passed on the command line.
143- 4 . The last opened workspace or folder .
142+ 3 . The workspace or directory passed on the command line.
143+ 4 . The last opened workspace or directory .
144144
145145## Enterprise
146146
Original file line number Diff line number Diff line change 11import { field , logger } from "@coder/logger"
22import * as cp from "child_process"
33import * as crypto from "crypto"
4+ import * as fs from "fs-extra"
45import * as http from "http"
56import * as net from "net"
67import * as path from "path"
@@ -209,14 +210,26 @@ export class VscodeHttpProvider extends HttpProvider {
209210 private async getFirstPath (
210211 startPaths : Array < { url ?: string | string [ ] ; workspace ?: boolean } | undefined > ,
211212 ) : Promise < StartPath | undefined > {
213+ const isFile = async ( path : string ) : Promise < boolean > => {
214+ try {
215+ const stat = await fs . stat ( path )
216+ return stat . isFile ( )
217+ } catch ( error ) {
218+ logger . warn ( error . message )
219+ return false
220+ }
221+ }
212222 for ( let i = 0 ; i < startPaths . length ; ++ i ) {
213223 const startPath = startPaths [ i ]
214224 const url =
215225 startPath && ( typeof startPath . url === "string" ? [ startPath . url ] : startPath . url || [ ] ) . find ( ( p ) => ! ! p )
216226 if ( startPath && url ) {
217227 return {
218228 url,
219- workspace : ! ! startPath . workspace ,
229+ // The only time `workspace` is undefined is for the command-line
230+ // argument, in which case it's a path (not a URL) so we can stat it
231+ // without having to parse it.
232+ workspace : typeof startPath . workspace !== "undefined" ? startPath . workspace : await isFile ( url ) ,
220233 }
221234 }
222235 }
You can’t perform that action at this time.
0 commit comments