Archived
1
0

Add separate function for VS Code arguments (#4599)

The problem before was that the pop() caused the open in existing
instance functionality to break because the arguments no longer
contained the file.

We could simply remove the pop() but since `workspace` and `folder` are
not CLI arguments I think it makes sense to handle them in a separate
function which can be called at the point where they are needed.  This
also lets us de-duplicate some logic since we create these arguments in
two spots and lets us skip this logic when we do not need it.

The pop() is still avoided because manipulating a passed-in object
in-place seems like a risky move.  If we really need to do this we
should copy the positional argument array instead.
This commit is contained in:
Asher
2021-12-10 12:01:35 -06:00
committed by GitHub
parent 3b91cffae5
commit 9e583fa562
5 changed files with 112 additions and 58 deletions

View File

@ -3,6 +3,7 @@ import * as express from "express"
import { WebsocketRequest } from "../../../typings/pluginapi"
import { logError } from "../../common/util"
import { isDevMode } from "../constants"
import { toVsCodeArgs } from "../cli"
import { ensureAuthenticated, authenticated, redirect } from "../http"
import { loadAMDModule, readCompilationStats } from "../util"
import { Router as WsRouter } from "../wsRouter"
@ -87,15 +88,7 @@ export class CodeServerRouteWrapper {
)
try {
this._codeServerMain = await createVSServer(null, {
"connection-token": "0000",
"accept-server-license-terms": true,
...args,
/** Type casting. */
help: !!args.help,
version: !!args.version,
port: args.port?.toString(),
})
this._codeServerMain = await createVSServer(null, await toVsCodeArgs(args))
} catch (createServerError) {
logError(logger, "CodeServerRouteWrapper", createServerError)
return next(createServerError)