@@ -1466,10 +1466,10 @@ index 0000000000000000000000000000000000000000..6ce56bec114a6d8daf5dd3ded945ea78
14661466+ }
14671467diff --git a/src/vs/server/node/channel.ts b/src/vs/server/node/channel.ts
14681468new file mode 100644
1469- index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c5d0b7821
1469+ index 0000000000000000000000000000000000000000..7619b02f04b6e61e86e741b09b542d86fab97e3d
14701470--- /dev/null
14711471+++ b/src/vs/server/node/channel.ts
1472- @@ -0,0 +1,869 @@
1472+ @@ -0,0 +1,887 @@
14731473+ import { field, logger } from '@coder/logger';
14741474+ import { Server } from '@coder/node-browser';
14751475+ import * as os from 'os';
@@ -1846,30 +1846,51 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
18461846+ }
18471847+
18481848+ class VariableResolverService extends AbstractVariableResolverService {
1849- + constructor(folders: terminal.IWorkspaceFolderData[], env: platform.IProcessEnvironment) {
1849+ + constructor(
1850+ + remoteAuthority: string,
1851+ + args: terminal.ICreateTerminalProcessArguments,
1852+ + env: platform.IProcessEnvironment,
1853+ + ) {
18501854+ super({
18511855+ getFolderUri: (name: string): URI | undefined => {
1852- + const folder = folders .find((f) => f.name === name);
1856+ + const folder = args.workspaceFolders .find((f) => f.name === name);
18531857+ return folder && URI.revive(folder.uri);
18541858+ },
18551859+ getWorkspaceFolderCount: (): number => {
1856- + return folders .length;
1860+ + return args.workspaceFolders .length;
18571861+ },
1858- + getConfigurationValue: (uri: URI, section: string): string | undefined => {
1859- + throw new Error("not implemented");
1862+ + // In ../../workbench/contrib/terminal/common/remoteTerminalChannel.ts it
1863+ + // looks like there are `config:` entries which must be for this? Not sure
1864+ + // how/if the URI comes into play though.
1865+ + getConfigurationValue: (_: URI, section: string): string | undefined => {
1866+ + return args.resolvedVariables[`config:${section}`];
18601867+ },
18611868+ getExecPath: (): string | undefined => {
18621869+ return env['VSCODE_EXEC_PATH'];
18631870+ },
1871+ + // This is just a guess; this is the only file-related thing we're sent
1872+ + // and none of these resolver methods seem to get called so I don't know
1873+ + // how to test.
18641874+ getFilePath: (): string | undefined => {
1865- + throw new Error("not implemented");
1875+ + const resource = transformIncoming(remoteAuthority, args.activeFileResource);
1876+ + if (!resource) {
1877+ + return undefined;
1878+ + }
1879+ + // See ../../editor/standalone/browser/simpleServices.ts;
1880+ + // `BaseConfigurationResolverService` calls `getUriLabel` from there.
1881+ + if (resource.scheme === 'file') {
1882+ + return resource.fsPath;
1883+ + }
1884+ + return resource.path;
18661885+ },
1886+ + // It looks like these are set here although they aren't on the types:
1887+ + // ../../workbench/contrib/terminal/common/remoteTerminalChannel.ts
18671888+ getSelectedText: (): string | undefined => {
1868- + throw new Error("not implemented") ;
1889+ + return args.resolvedVariables.selectedText ;
18691890+ },
18701891+ getLineNumber: (): string | undefined => {
1871- + throw new Error("not implemented") ;
1872- + }
1892+ + return args.resolvedVariables.selectedText ;
1893+ + },
18731894+ }, undefined, env);
18741895+ }
18751896+ }
@@ -2144,20 +2165,22 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
21442165+ name: args.shellLaunchConfig.name,
21452166+ executable: args.shellLaunchConfig.executable,
21462167+ args: args.shellLaunchConfig.args,
2147- + cwd: this.transform(remoteAuthority, args.shellLaunchConfig.cwd),
2168+ + // TODO: Should we transform if it's a string as well? The incoming
2169+ + // transform only takes `UriComponents` so I suspect it's not necessary.
2170+ + cwd: typeof args.shellLaunchConfig.cwd !== "string"
2171+ + ? transformIncoming(remoteAuthority, args.shellLaunchConfig.cwd)
2172+ + : args.shellLaunchConfig.cwd,
21482173+ env: args.shellLaunchConfig.env,
21492174+ };
21502175+
2151- + // TODO: is this supposed to be the *last* workspace?
2152- +
2153- + const activeWorkspaceUri = this.transform(remoteAuthority, args.activeWorkspaceFolder?.uri);
2176+ + const activeWorkspaceUri = transformIncoming(remoteAuthority, args.activeWorkspaceFolder?.uri);
21542177+ const activeWorkspace = activeWorkspaceUri && args.activeWorkspaceFolder ? {
21552178+ ...args.activeWorkspaceFolder,
21562179+ uri: activeWorkspaceUri,
21572180+ toResource: (relativePath: string) => resources.joinPath(activeWorkspaceUri, relativePath),
21582181+ } : undefined;
21592182+
2160- + const resolverService = new VariableResolverService(args.workspaceFolders , process.env as platform.IProcessEnvironment);
2183+ + const resolverService = new VariableResolverService(remoteAuthority, args, process.env as platform.IProcessEnvironment);
21612184+ const resolver = terminalEnvironment.createVariableResolver(activeWorkspace, resolverService);
21622185+
21632186+ const getDefaultShellAndArgs = (): { executable: string; args: string[] | string } => {
@@ -2269,16 +2292,6 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
22692292+ };
22702293+ }
22712294+
2272- + private transform(remoteAuthority: string, uri: UriComponents | undefined): URI | undefined
2273- + private transform(remoteAuthority: string, uri: string | UriComponents | undefined): string | URI | undefined
2274- + private transform(remoteAuthority: string, uri: string | UriComponents | undefined): string | URI | undefined {
2275- + if (typeof uri === 'string') {
2276- + return uri;
2277- + }
2278- + const transformer = getUriTransformer(remoteAuthority);
2279- + return uri ? URI.revive(transformer.transformIncoming(uri)) : uri;
2280- + }
2281- +
22822295+ private getTerminal(id: number): Terminal {
22832296+ const terminal = this.terminals.get(id);
22842297+ if (!terminal) {
@@ -2339,6 +2352,11 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
23392352+ }));
23402353+ }
23412354+ }
2355+ +
2356+ + function transformIncoming(remoteAuthority: string, uri: UriComponents | undefined): URI | undefined {
2357+ + const transformer = getUriTransformer(remoteAuthority);
2358+ + return uri ? URI.revive(transformer.transformIncoming(uri)) : uri;
2359+ + }
23422360diff --git a/src/vs/server/node/connection.ts b/src/vs/server/node/connection.ts
23432361new file mode 100644
23442362index 0000000000000000000000000000000000000000..93062cadc627c61e0829c27a72894b81e6a0e039
0 commit comments