From d808bfaec68015a55b7056fce12e64a447c8d726 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 2 Jul 2019 10:59:36 -0500 Subject: [PATCH] Set workspace and folder URIs This makes the file tree work. --- server.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server.ts b/server.ts index d774d7cf..4f0a7f48 100644 --- a/server.ts +++ b/server.ts @@ -6,6 +6,7 @@ import * as util from "util"; import * as url from "url"; import { Emitter } from "vs/base/common/event"; +import { sanitizeFilePath } from "vs/base/common/extpath"; import { getMediaMime } from "vs/base/common/mime"; import { extname } from "vs/base/common/path"; import { UriComponents, URI } from "vs/base/common/uri"; @@ -139,7 +140,8 @@ export class Server { ); } - const requestPath = url.parse(request.url || "").pathname || "/"; + const parsedUrl = url.parse(request.url || "", true); + const requestPath = parsedUrl.pathname || "/"; if (requestPath === "/") { const htmlPath = path.join( this.rootPath, @@ -151,8 +153,14 @@ export class Server { const remoteAuthority = request.headers.host as string; const transformer = getUriTransformer(remoteAuthority); + const cwd = process.env.VSCODE_CWD || process.cwd(); + const workspacePath = parsedUrl.query.workspace as string | undefined; + const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || cwd: undefined; + const options: Options = { WORKBENCH_WEB_CONGIGURATION: { + workspaceUri: workspacePath ? transformer.transformOutgoing(URI.file(sanitizeFilePath(workspacePath, cwd))) : undefined, + folderUri: folderPath ? transformer.transformOutgoing(URI.file(sanitizeFilePath(folderPath, cwd))) : undefined, remoteAuthority, }, REMOTE_USER_DATA_URI: transformer.transformOutgoing(this.environmentService.webUserDataHome),