提交 3e98ad51 编写于 作者: M Martin Aeschlimann

add 'remoteName' context key (replaces remoteAuthority)

上级 b4e3cf33
......@@ -10,4 +10,16 @@ export const REMOTE_HOST_SCHEME = Schemas.vscodeRemote;
export function getRemoteAuthority(uri: URI): string | undefined {
return uri.scheme === REMOTE_HOST_SCHEME ? uri.authority : undefined;
}
export function getRemoteName(authority: string | undefined): string | undefined {
if (!authority) {
return undefined;
}
const pos = authority.indexOf('+');
if (pos < 0) {
// funky? bad authority?
return authority;
}
return authority.substr(0, pos);
}
\ No newline at end of file
......@@ -72,6 +72,7 @@ import { ExtHostLabelService } from 'vs/workbench/api/common/extHostLabelService
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { getSingletonServiceDescriptors } from 'vs/platform/instantiation/common/extensions';
import { getRemoteName } from 'vs/platform/remote/common/remoteHosts';
export interface IExtensionApiFactory {
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
......@@ -277,15 +278,7 @@ export function createApiFactory(
return extHostWindow.openUri(uri, { allowTunneling: !!initData.remote.isRemote });
},
get remoteName() {
if (!initData.remote.authority) {
return undefined;
}
const pos = initData.remote.authority.indexOf('+');
if (pos < 0) {
// funky? bad authority?
return initData.remote.authority;
}
return initData.remote.authority.substr(0, pos);
return getRemoteName(initData.remote.authority);
}
};
if (!initData.environment.extensionTestsLocationURI) {
......
......@@ -20,6 +20,7 @@ import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { isMacintosh, isLinux, isWindows, isWeb } from 'vs/base/common/platform';
import { PanelPositionContext } from 'vs/workbench/common/panel';
import { getRemoteName } from 'vs/platform/remote/common/remoteHosts';
export const IsMacContext = new RawContextKey<boolean>('isMac', isMacintosh);
export const IsLinuxContext = new RawContextKey<boolean>('isLinux', isLinux);
......@@ -28,8 +29,9 @@ export const IsWindowsContext = new RawContextKey<boolean>('isWindows', isWindow
export const IsWebContext = new RawContextKey<boolean>('isWeb', isWeb);
export const IsMacNativeContext = new RawContextKey<boolean>('isMacNative', isMacintosh && !isWeb);
export const RemoteAuthorityContext = new RawContextKey<string>('remoteAuthority', '');
export const Deprecated_RemoteAuthorityContext = new RawContextKey<string>('remoteAuthority', '');
export const RemoteNameContext = new RawContextKey<string>('remoteName', '');
export const RemoteConnectionState = new RawContextKey<'' | 'initializing' | 'disconnected' | 'connected'>('remoteConnectionState', '');
export const HasMacNativeTabsContext = new RawContextKey<boolean>('hasMacNativeTabs', false);
......@@ -121,7 +123,8 @@ export class WorkbenchContextKeysHandler extends Disposable {
IsWebContext.bindTo(this.contextKeyService);
IsMacNativeContext.bindTo(this.contextKeyService);
RemoteAuthorityContext.bindTo(this.contextKeyService).set(this.environmentService.configuration.remoteAuthority || '');
Deprecated_RemoteAuthorityContext.bindTo(this.contextKeyService).set(this.environmentService.configuration.remoteAuthority || ''); // remove once
RemoteNameContext.bindTo(this.contextKeyService).set(getRemoteName(this.environmentService.configuration.remoteAuthority) || '');
// macOS Native Tabs
const windowConfig = this.configurationService.getValue<IWindowsConfiguration>();
......
......@@ -55,7 +55,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
import { Registry } from 'vs/platform/registry/common/platform';
import { ViewContainerViewlet } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { RemoteAuthorityContext } from 'vs/workbench/browser/contextkeys';
import { RemoteNameContext } from 'vs/workbench/browser/contextkeys';
import { ILabelService } from 'vs/platform/label/common/label';
import { MementoObject } from 'vs/workbench/common/memento';
......@@ -144,7 +144,7 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
id,
name: viewIdNameMappings[id],
ctorDescriptor: { ctor: EnabledExtensionsView },
when: ContextKeyExpr.and(ContextKeyExpr.has('defaultExtensionViews'), ContextKeyExpr.has('hasInstalledExtensions'), RemoteAuthorityContext.isEqualTo('')),
when: ContextKeyExpr.and(ContextKeyExpr.has('defaultExtensionViews'), ContextKeyExpr.has('hasInstalledExtensions'), RemoteNameContext.isEqualTo('')),
weight: 40,
canToggleVisibility: true,
order: 1
......@@ -159,7 +159,7 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
id,
name: viewIdNameMappings[id],
ctorDescriptor: { ctor: DisabledExtensionsView },
when: ContextKeyExpr.and(ContextKeyExpr.has('defaultExtensionViews'), ContextKeyExpr.has('hasInstalledExtensions'), RemoteAuthorityContext.isEqualTo('')),
when: ContextKeyExpr.and(ContextKeyExpr.has('defaultExtensionViews'), ContextKeyExpr.has('hasInstalledExtensions'), RemoteNameContext.isEqualTo('')),
weight: 10,
canToggleVisibility: true,
order: 3,
......@@ -208,7 +208,7 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
id: `extensions.${server.authority}.default`,
get name() { return getInstalledViewName(); },
ctorDescriptor: { ctor: ServerExtensionsView, arguments: [server, EventOf.map<void, string>(onDidChangeServerLabel, () => getInstalledViewName())] },
when: ContextKeyExpr.and(ContextKeyExpr.has('defaultExtensionViews'), ContextKeyExpr.has('hasInstalledExtensions'), RemoteAuthorityContext.notEqualsTo('')),
when: ContextKeyExpr.and(ContextKeyExpr.has('defaultExtensionViews'), ContextKeyExpr.has('hasInstalledExtensions'), RemoteNameContext.notEqualsTo('')),
weight: 40,
order: 1
}];
......
......@@ -13,7 +13,7 @@ import * as nls from 'vs/nls';
import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { WorkbenchStateContext, RemoteAuthorityContext, IsMacNativeContext } from 'vs/workbench/browser/contextkeys';
import { WorkbenchStateContext, IsMacNativeContext, RemoteNameContext } from 'vs/workbench/browser/contextkeys';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
......@@ -424,7 +424,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
title: { value: label, original: `Open Remote Settings (${hostLabel})` },
category: { value: nls.localize('preferencesCategory', "Preferences"), original: 'Preferences' }
},
when: RemoteAuthorityContext.notEqualsTo('')
when: RemoteNameContext.notEqualsTo('')
});
});
}
......
......@@ -37,7 +37,7 @@ import Severity from 'vs/base/common/severity';
import { ReloadWindowAction } from 'vs/workbench/browser/actions/windowActions';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { RemoteConnectionState } from 'vs/workbench/browser/contextkeys';
import { RemoteConnectionState, Deprecated_RemoteAuthorityContext } from 'vs/workbench/browser/contextkeys';
import { IDownloadService } from 'vs/platform/download/common/download';
const WINDOW_ACTIONS_COMMAND_ID = 'remote.showActions';
......@@ -119,6 +119,7 @@ export class RemoteWindowActiveIndicator extends Disposable implements IWorkbenc
if (this.disconnected !== isDisconnected) {
this.disconnected = isDisconnected;
RemoteConnectionState.bindTo(this.contextKeyService).set(isDisconnected ? 'disconnected' : 'connected');
Deprecated_RemoteAuthorityContext.bindTo(this.contextKeyService).set(!isDisconnected && this.remoteAuthority || '');
this.updateWindowIndicator();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册