diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index a08a922651d..7c034b314c1 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -6042,15 +6042,19 @@ declare module 'vscode' { export function openExternal(target: Uri): Thenable; /** - * The [authority](#Uri.authority)-component. When `undefined`, extensions are - * executed in the same context (e.g. operating system or machine) in which the UI - * of the editor is executed. If defined, extensions are running in a different - * context, for instance a remote machine. + * Information about running remotely. When `undefined`, extensions are executed in the same + * context (e.g. operating system or machine) in which the UI of the editor is executed. + * If defined, extensions are running in a different context, for instance a remote machine. * - * *Note* that no assumptions about the actual value should be made as it is defined - * by extensions and not by the editor. + * A remote [uri](#Uri) adheres to this format: `remote_scheme://auth_prefix+auth_rest/path` where + * the `remote_scheme` is defined by the editor, `auth_prefix` and `auth_rest` are defined by extensions, + * and `path` is defined by the user. + * + * Extensions contributing a remote are encouraged to use a stable `auth_prefix`-value, + * e.g `remote_scheme://ssh+23/` and `remote_scheme://ssh+42`. Such prefix is exposed + * in the `prefix`-property of the returned object. */ - export const remoteAuthority: string | undefined; + export const remoteAuthority: { prefix: string } | undefined; } /** diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 272dc9788e3..c46ff996455 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -236,7 +236,7 @@ export function createApiFactory( }; // namespace: env - const env: typeof vscode.env = Object.freeze({ + const env: typeof vscode.env = Object.freeze({ get machineId() { return initData.telemetryInfo.machineId; }, get sessionId() { return initData.telemetryInfo.sessionId; }, get language() { return initData.environment.appLanguage; }, @@ -257,7 +257,21 @@ export function createApiFactory( openExternal(uri: URI) { return extHostWindow.openUri(uri, { allowTunneling: !!initData.remoteAuthority }); }, - get remoteAuthority() { return initData.remoteAuthority || undefined; } + get remoteAuthority() { + const { remoteAuthority } = initData; + if (!remoteAuthority) { + return undefined; + } + const idx = remoteAuthority.indexOf('+'); + if (idx < 0) { + console.warn(`INVALID remote authority: ${remoteAuthority}`); + return undefined; + } + return { + prefix: remoteAuthority.substring(0, idx), + toString() { return remoteAuthority; } // compatiblity + }; + } }); // namespace: extensions