Skip to content

Commit d808bfa

Browse files
committed
Set workspace and folder URIs
This makes the file tree work.
1 parent 7072bf1 commit d808bfa

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as util from "util";
66
import * as url from "url";
77

88
import { Emitter } from "vs/base/common/event";
9+
import { sanitizeFilePath } from "vs/base/common/extpath";
910
import { getMediaMime } from "vs/base/common/mime";
1011
import { extname } from "vs/base/common/path";
1112
import { UriComponents, URI } from "vs/base/common/uri";
@@ -139,7 +140,8 @@ export class Server {
139140
);
140141
}
141142

142-
const requestPath = url.parse(request.url || "").pathname || "/";
143+
const parsedUrl = url.parse(request.url || "", true);
144+
const requestPath = parsedUrl.pathname || "/";
143145
if (requestPath === "/") {
144146
const htmlPath = path.join(
145147
this.rootPath,
@@ -151,8 +153,14 @@ export class Server {
151153
const remoteAuthority = request.headers.host as string;
152154
const transformer = getUriTransformer(remoteAuthority);
153155

156+
const cwd = process.env.VSCODE_CWD || process.cwd();
157+
const workspacePath = parsedUrl.query.workspace as string | undefined;
158+
const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || cwd: undefined;
159+
154160
const options: Options = {
155161
WORKBENCH_WEB_CONGIGURATION: {
162+
workspaceUri: workspacePath ? transformer.transformOutgoing(URI.file(sanitizeFilePath(workspacePath, cwd))) : undefined,
163+
folderUri: folderPath ? transformer.transformOutgoing(URI.file(sanitizeFilePath(folderPath, cwd))) : undefined,
156164
remoteAuthority,
157165
},
158166
REMOTE_USER_DATA_URI: transformer.transformOutgoing(this.environmentService.webUserDataHome),

0 commit comments

Comments
 (0)