File tree 2 files changed +16
-3
lines changed
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:
139
139
140
140
1 . The ` workspace ` query parameter.
141
141
2 . 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 .
144
144
145
145
## Enterprise
146
146
Original file line number Diff line number Diff line change 1
1
import { field , logger } from "@coder/logger"
2
2
import * as cp from "child_process"
3
3
import * as crypto from "crypto"
4
+ import * as fs from "fs-extra"
4
5
import * as http from "http"
5
6
import * as net from "net"
6
7
import * as path from "path"
@@ -209,14 +210,26 @@ export class VscodeHttpProvider extends HttpProvider {
209
210
private async getFirstPath (
210
211
startPaths : Array < { url ?: string | string [ ] ; workspace ?: boolean } | undefined > ,
211
212
) : 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
+ }
212
222
for ( let i = 0 ; i < startPaths . length ; ++ i ) {
213
223
const startPath = startPaths [ i ]
214
224
const url =
215
225
startPath && ( typeof startPath . url === "string" ? [ startPath . url ] : startPath . url || [ ] ) . find ( ( p ) => ! ! p )
216
226
if ( startPath && url ) {
217
227
return {
218
228
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 ) ,
220
233
}
221
234
}
222
235
}
You can’t perform that action at this time.
0 commit comments