From e22791ec88da233aba7c8e19e0f6f50dc5b9c337 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 12 Jul 2019 17:13:49 -0500 Subject: [PATCH] Fix interactive playground --- scripts/vscode.patch | 7 ++++--- src/channel.ts | 29 ++++++++++++++++++++--------- src/server.ts | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 4b9b245d..9a884753 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -202,19 +202,20 @@ index e09049c5b9..d93ffa527a 100644 \ No newline at end of file +} diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts -index 1986fb6642..7c66b644f2 100644 +index 1986fb6642..afbe385af6 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts -@@ -115,6 +115,8 @@ class CodeRendererMain extends Disposable { +@@ -115,6 +115,9 @@ class CodeRendererMain extends Disposable { const remoteFileSystemProvider = this._register(new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment())); fileService.registerProvider(Schemas.vscodeRemote, remoteFileSystemProvider); + fileService.registerProvider(Schemas.http, remoteFileSystemProvider); + fileService.registerProvider(Schemas.https, remoteFileSystemProvider); ++ fileService.registerProvider(Schemas.file, remoteFileSystemProvider); } const payload = await this.resolveWorkspaceInitializationPayload(); -@@ -170,4 +172,4 @@ export function main(domElement: HTMLElement, options: IWorkbenchConstructionOpt +@@ -170,4 +173,4 @@ export function main(domElement: HTMLElement, options: IWorkbenchConstructionOpt const renderer = new CodeRendererMain(domElement, options); return renderer.open(); diff --git a/src/channel.ts b/src/channel.ts index 72d16854..fa6e606f 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -49,7 +49,10 @@ export class FileProviderChannel implements IServerChannel, IDisposable { private readonly provider: DiskFileSystemProvider; private readonly watchers = new Map(); - public constructor(private readonly logService: ILogService) { + public constructor( + private readonly environmentService: IEnvironmentService, + private readonly logService: ILogService, + ) { this.provider = new DiskFileSystemProvider(this.logService); } @@ -113,11 +116,11 @@ export class FileProviderChannel implements IServerChannel, IDisposable { } private async stat(resource: UriComponents): Promise { - return this.provider.stat(URI.from(resource)); + return this.provider.stat(this.transform(resource)); } private async open(resource: UriComponents, opts: FileOpenOptions): Promise { - return this.provider.open(URI.from(resource), opts); + return this.provider.open(this.transform(resource), opts); } private async close(fd: number): Promise { @@ -135,32 +138,40 @@ export class FileProviderChannel implements IServerChannel, IDisposable { } private async delete(resource: UriComponents, opts: FileDeleteOptions): Promise { - return this.provider.delete(URI.from(resource), opts); + return this.provider.delete(this.transform(resource), opts); } private async mkdir(resource: UriComponents): Promise { - return this.provider.mkdir(URI.from(resource)); + return this.provider.mkdir(this.transform(resource)); } private async readdir(resource: UriComponents): Promise<[string, FileType][]> { - return this.provider.readdir(URI.from(resource)); + return this.provider.readdir(this.transform(resource)); } private async rename(resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): Promise { - return this.provider.rename(URI.from(resource), URI.from(target), opts); + return this.provider.rename(this.transform(resource), URI.from(target), opts); } private copy(resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): Promise { - return this.provider.copy(URI.from(resource), URI.from(target), opts); + return this.provider.copy(this.transform(resource), URI.from(target), opts); } private async watch(session: string, req: number, resource: UriComponents, opts: IWatchOptions): Promise { - this.watchers.get(session)!._watch(req, URI.from(resource), opts); + this.watchers.get(session)!._watch(req, this.transform(resource), opts); } private async unwatch(session: string, req: number): Promise { this.watchers.get(session)!.unwatch(req); } + + private transform(resource: UriComponents): URI { + // HACK: for now assume /out is relative to the build. + if (resource.path.indexOf("/out") === 0) { + resource.path = this.environmentService.appRoot + resource.path; + } + return URI.from(resource); + } } /** diff --git a/src/server.ts b/src/server.ts index 50054c58..50e9dd4d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -402,7 +402,7 @@ export class MainServer extends Server { instantiationService.invokeFunction(() => { instantiationService.createInstance(LogsDataCleaner); - this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, new FileProviderChannel(logService)); + this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, new FileProviderChannel(environmentService, logService)); this.ipc.registerChannel("remoteextensionsenvironment", new ExtensionEnvironmentChannel(environmentService, logService)); const extensionsService = this.services.get(IExtensionManagementService) as IExtensionManagementService; const extensionsChannel = new ExtensionManagementChannel(extensionsService, (context) => getUriTransformer(context.remoteAuthority));