@@ -1466,10 +1466,10 @@ index 0000000000000000000000000000000000000000..6ce56bec114a6d8daf5dd3ded945ea78
1466
1466
+ }
1467
1467
diff --git a/src/vs/server/node/channel.ts b/src/vs/server/node/channel.ts
1468
1468
new file mode 100644
1469
- index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c5d0b7821
1469
+ index 0000000000000000000000000000000000000000..7619b02f04b6e61e86e741b09b542d86fab97e3d
1470
1470
--- /dev/null
1471
1471
+++ b/src/vs/server/node/channel.ts
1472
- @@ -0,0 +1,869 @@
1472
+ @@ -0,0 +1,887 @@
1473
1473
+ import { field, logger } from '@coder/logger';
1474
1474
+ import { Server } from '@coder/node-browser';
1475
1475
+ import * as os from 'os';
@@ -1846,30 +1846,51 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
1846
1846
+ }
1847
1847
+
1848
1848
+ 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
+ + ) {
1850
1854
+ super({
1851
1855
+ getFolderUri: (name: string): URI | undefined => {
1852
- + const folder = folders .find((f) => f.name === name);
1856
+ + const folder = args.workspaceFolders .find((f) => f.name === name);
1853
1857
+ return folder && URI.revive(folder.uri);
1854
1858
+ },
1855
1859
+ getWorkspaceFolderCount: (): number => {
1856
- + return folders .length;
1860
+ + return args.workspaceFolders .length;
1857
1861
+ },
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}`];
1860
1867
+ },
1861
1868
+ getExecPath: (): string | undefined => {
1862
1869
+ return env['VSCODE_EXEC_PATH'];
1863
1870
+ },
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.
1864
1874
+ 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;
1866
1885
+ },
1886
+ + // It looks like these are set here although they aren't on the types:
1887
+ + // ../../workbench/contrib/terminal/common/remoteTerminalChannel.ts
1867
1888
+ getSelectedText: (): string | undefined => {
1868
- + throw new Error("not implemented") ;
1889
+ + return args.resolvedVariables.selectedText ;
1869
1890
+ },
1870
1891
+ getLineNumber: (): string | undefined => {
1871
- + throw new Error("not implemented") ;
1872
- + }
1892
+ + return args.resolvedVariables.selectedText ;
1893
+ + },
1873
1894
+ }, undefined, env);
1874
1895
+ }
1875
1896
+ }
@@ -2144,20 +2165,22 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
2144
2165
+ name: args.shellLaunchConfig.name,
2145
2166
+ executable: args.shellLaunchConfig.executable,
2146
2167
+ 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,
2148
2173
+ env: args.shellLaunchConfig.env,
2149
2174
+ };
2150
2175
+
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);
2154
2177
+ const activeWorkspace = activeWorkspaceUri && args.activeWorkspaceFolder ? {
2155
2178
+ ...args.activeWorkspaceFolder,
2156
2179
+ uri: activeWorkspaceUri,
2157
2180
+ toResource: (relativePath: string) => resources.joinPath(activeWorkspaceUri, relativePath),
2158
2181
+ } : undefined;
2159
2182
+
2160
- + const resolverService = new VariableResolverService(args.workspaceFolders , process.env as platform.IProcessEnvironment);
2183
+ + const resolverService = new VariableResolverService(remoteAuthority, args, process.env as platform.IProcessEnvironment);
2161
2184
+ const resolver = terminalEnvironment.createVariableResolver(activeWorkspace, resolverService);
2162
2185
+
2163
2186
+ const getDefaultShellAndArgs = (): { executable: string; args: string[] | string } => {
@@ -2269,16 +2292,6 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
2269
2292
+ };
2270
2293
+ }
2271
2294
+
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
- +
2282
2295
+ private getTerminal(id: number): Terminal {
2283
2296
+ const terminal = this.terminals.get(id);
2284
2297
+ if (!terminal) {
@@ -2339,6 +2352,11 @@ index 0000000000000000000000000000000000000000..7081bbf178c660803830675a4d8d596c
2339
2352
+ }));
2340
2353
+ }
2341
2354
+ }
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
+ + }
2342
2360
diff --git a/src/vs/server/node/connection.ts b/src/vs/server/node/connection.ts
2343
2361
new file mode 100644
2344
2362
index 0000000000000000000000000000000000000000..93062cadc627c61e0829c27a72894b81e6a0e039
0 commit comments