Merge from vscode de81ccf04849309f843db21130c806a5783678f7 (#4738)

This commit is contained in:
Anthony Dresser
2019-03-28 13:06:16 -07:00
committed by GitHub
parent cc2951265e
commit e6785ffe95
77 changed files with 562 additions and 835 deletions

View File

@@ -91,7 +91,6 @@ export class OpenGlobalSettingsAction extends Action {
export class OpenRemoteSettingsAction extends Action {
static readonly ID = 'workbench.action.openRemoteSettings';
static readonly LABEL = nls.localize('openRemoteSettings', "Open User Settings (Remote)");
constructor(
id: string,

View File

@@ -1220,7 +1220,16 @@ export class SettingsTreeFilter implements ITreeFilter<SettingsTreeElement> {
}
class SettingsTreeDelegate implements IListVirtualDelegate<SettingsTreeGroupChild> {
getHeight(element: SettingsTreeElement): number {
private heightCache = new WeakMap<SettingsTreeGroupChild, number>();
getHeight(element: SettingsTreeGroupChild): number {
const cachedHeight = this.heightCache.get(element);
if (typeof cachedHeight === 'number') {
return cachedHeight;
}
if (element instanceof SettingsTreeGroupElement) {
if (element.isFirstGroup) {
return 31;
@@ -1273,6 +1282,10 @@ class SettingsTreeDelegate implements IListVirtualDelegate<SettingsTreeGroupChil
hasDynamicHeight(element: SettingsTreeGroupElement | SettingsTreeSettingElement | SettingsTreeNewExtensionsElement): boolean {
return !(element instanceof SettingsTreeGroupElement);
}
setDynamicHeight(element: SettingsTreeGroupChild, height: number): void {
this.heightCache.set(element, height);
}
}
class NonCollapsibleObjectTreeModel<T> extends ObjectTreeModel<T> {

View File

@@ -38,6 +38,10 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { DefaultPreferencesEditorInput, KeybindingsEditorInput, PreferencesEditorInput, SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
import { ExplorerRootContext, ExplorerFolderContext } from 'vs/workbench/contrib/files/common/files';
import { ILabelService } from 'vs/platform/label/common/label';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
registerSingleton(IPreferencesSearchService, PreferencesSearchService, true);
@@ -385,7 +389,10 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
constructor(
@IEnvironmentService environmentService: IEnvironmentService,
@IPreferencesService private readonly preferencesService: IPreferencesService,
@IWorkspaceContextService private readonly workpsaceContextService: IWorkspaceContextService
@IWorkspaceContextService private readonly workpsaceContextService: IWorkspaceContextService,
@ILabelService labelService: ILabelService,
@IExtensionService extensionService: IExtensionService,
@IWindowService windowService: IWindowService
) {
super();
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
@@ -418,10 +425,27 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
order: 1
});
this.updatePreferencesEditorMenuItem();
this._register(workpsaceContextService.onDidChangeWorkbenchState(() => this.updatePreferencesEditorMenuItem()));
this._register(workpsaceContextService.onDidChangeWorkspaceFolders(() => this.updatePreferencesEditorMenuItemForWorkspaceFolders()));
extensionService.whenInstalledExtensionsRegistered()
.then(() => {
const remoteAuthority = windowService.getConfiguration().remoteAuthority;
const hostLabel = labelService.getHostLabel(REMOTE_HOST_SCHEME, remoteAuthority) || remoteAuthority;
const label = nls.localize('openRemoteSettings', "Open User Settings ({0})", hostLabel);
CommandsRegistry.registerCommand(OpenRemoteSettingsAction.ID, serviceAccessor => {
serviceAccessor.get(IInstantiationService).createInstance(OpenRemoteSettingsAction, OpenRemoteSettingsAction.ID, label).run();
});
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: {
id: OpenRemoteSettingsAction.ID,
title: { value: label, original: `Preferences: Open User Settings (${hostLabel})` },
category: nls.localize('preferencesCategory', "Preferences")
},
when: IsRemoteContext
});
});
}
private updatePreferencesEditorMenuItem() {
@@ -566,18 +590,6 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
group: '1_keyboard_preferences_actions'
});
CommandsRegistry.registerCommand(OpenRemoteSettingsAction.ID, serviceAccessor => {
serviceAccessor.get(IInstantiationService).createInstance(OpenRemoteSettingsAction, OpenRemoteSettingsAction.ID, OpenRemoteSettingsAction.LABEL).run();
});
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: {
id: OpenRemoteSettingsAction.ID,
title: { value: OpenRemoteSettingsAction.LABEL, original: 'Preferences: Open Remote Settings' },
category: nls.localize('preferencesCategory', "Preferences")
},
when: IsRemoteContext
});
abstract class SettingsCommand extends Command {
protected getPreferencesEditor(accessor: ServicesAccessor): PreferencesEditor | SettingsEditor2 | null {