Fix #21429
This commit is contained in:
parent
d9bfa14cd2
commit
9b237f995e
4 changed files with 25 additions and 51 deletions
|
@ -10,15 +10,14 @@ import { Registry } from 'vs/platform/platform';
|
|||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry';
|
||||
import { EditorInput, IEditorRegistry, Extensions as EditorExtensions, IEditorInputFactory } from 'vs/workbench/common/editor';
|
||||
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { DefaultPreferencesEditorInput, PreferencesEditor, PreferencesEditorInput } from 'vs/workbench/parts/preferences/browser/preferencesEditor';
|
||||
import { OpenGlobalSettingsAction, OpenGlobalKeybindingsAction, OpenWorkspaceSettingsAction, ConfigureLanguageBasedSettingsAction } from 'vs/workbench/parts/preferences/browser/preferencesActions';
|
||||
import { IPreferencesService, CONTEXT_DEFAULT_SETTINGS_EDITOR, DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL } from 'vs/workbench/parts/preferences/common/preferences';
|
||||
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
|
||||
import { PreferencesService } from 'vs/workbench/parts/preferences/browser/preferencesService';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { PreferencesContentProvider } from 'vs/workbench/parts/preferences/common/preferencesContentProvider';
|
||||
|
@ -136,14 +135,4 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenWorkspaceSettingsA
|
|||
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsAction, OpenGlobalKeybindingsAction.ID, OpenGlobalKeybindingsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_S) }), 'Preferences: Open Keyboard Shortcuts', category);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ConfigureLanguageBasedSettingsAction, ConfigureLanguageBasedSettingsAction.ID, ConfigureLanguageBasedSettingsAction.LABEL), 'Preferences: Configure Language Specific Settings', category);
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
command: {
|
||||
id: DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL,
|
||||
iconClass: 'collapseAll',
|
||||
title: nls.localize('collapseAll', "Collapse All")
|
||||
},
|
||||
when: ContextKeyExpr.and(CONTEXT_DEFAULT_SETTINGS_EDITOR),
|
||||
group: 'navigation'
|
||||
});
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(PreferencesContentProvider);
|
|
@ -11,7 +11,6 @@ import { Delayer } from 'vs/base/common/async';
|
|||
import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
|
||||
import { Registry } from 'vs/platform/platform';
|
||||
import { toResource, SideBySideEditorInput, EditorOptions, EditorInput, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor, EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
|
@ -24,14 +23,14 @@ import { CodeEditor } from 'vs/editor/browser/codeEditor';
|
|||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import {
|
||||
IPreferencesService, ISettingsGroup, ISetting, IFilterResult, IPreferencesEditorModel,
|
||||
CONTEXT_DEFAULT_SETTINGS_EDITOR, DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL, DEFAULT_EDITOR_COMMAND_FOCUS_SEARCH, ISettingsEditorModel
|
||||
CONTEXT_SETTINGS_EDITOR, SETTINGS_EDITOR_COMMAND_SEARCH, ISettingsEditorModel
|
||||
} from 'vs/workbench/parts/preferences/common/preferences';
|
||||
import { SettingsEditorModel, DefaultSettingsEditorModel } from 'vs/workbench/parts/preferences/common/preferencesModels';
|
||||
import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import { ICodeEditor, IEditorContributionCtor } from 'vs/editor/browser/editorBrowser';
|
||||
import { SearchWidget, SettingsTabsWidget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { CommonEditorRegistry, EditorCommand, Command } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ContextKeyExpr, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { CommonEditorRegistry, Command } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/workbench/services/themes/common/themeService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
|
@ -89,6 +88,7 @@ export class PreferencesEditor extends BaseEditor {
|
|||
|
||||
public static ID: string = 'workbench.editor.preferencesEditor';
|
||||
|
||||
private defaultSettingsEditorContextKey: IContextKey<boolean>;
|
||||
private headerContainer: HTMLElement;
|
||||
private searchWidget: SearchWidget;
|
||||
private settingsTabsWidget: SettingsTabsWidget;
|
||||
|
@ -104,9 +104,11 @@ export class PreferencesEditor extends BaseEditor {
|
|||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
) {
|
||||
super(PreferencesEditor.ID, telemetryService);
|
||||
this.defaultSettingsEditorContextKey = CONTEXT_SETTINGS_EDITOR.bindTo(this.contextKeyService);
|
||||
this.delayedFilterLogging = new Delayer<void>(1000);
|
||||
}
|
||||
|
||||
|
@ -129,6 +131,7 @@ export class PreferencesEditor extends BaseEditor {
|
|||
}
|
||||
|
||||
public setInput(newInput: PreferencesEditorInput, options?: EditorOptions): TPromise<void> {
|
||||
this.defaultSettingsEditorContextKey.set(true);
|
||||
const oldInput = <PreferencesEditorInput>this.input;
|
||||
return super.setInput(newInput, options).then(() => this.updateInput(oldInput, newInput, options));
|
||||
}
|
||||
|
@ -148,7 +151,12 @@ export class PreferencesEditor extends BaseEditor {
|
|||
this.sideBySidePreferencesWidget.focus();
|
||||
}
|
||||
|
||||
public focusSearch(): void {
|
||||
this.searchWidget.focus();
|
||||
}
|
||||
|
||||
public clearInput(): void {
|
||||
this.defaultSettingsEditorContextKey.set(false);
|
||||
this.sideBySidePreferencesWidget.clearInput();
|
||||
super.clearInput();
|
||||
}
|
||||
|
@ -586,37 +594,26 @@ export class SettingsEditorContribution extends PreferencesEditorContribution<IS
|
|||
}
|
||||
}
|
||||
|
||||
const DefaultSettingsEditorCommand = EditorCommand.bindToContribution<PreferencesEditorContribution<ISetting>>((editor: editorCommon.ICommonCodeEditor) => <PreferencesEditorContribution<ISetting>>editor.getContribution(DefaultSettingsEditorContribution.ID));
|
||||
|
||||
CommonEditorRegistry.registerEditorCommand(new DefaultSettingsEditorCommand({
|
||||
id: DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_DEFAULT_SETTINGS_EDITOR),
|
||||
handler: x => (<DefaultSettingsRenderer>x.getPreferencesRenderer()).collapseAll()
|
||||
}));
|
||||
|
||||
class StartSearchDefaultSettingsCommand extends Command {
|
||||
|
||||
public runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const defaultPreferencesEditor = this.getDefaultPreferencesEditor(accessor);
|
||||
if (defaultPreferencesEditor) {
|
||||
defaultPreferencesEditor.focus();
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
if (preferencesEditor) {
|
||||
preferencesEditor.focusSearch();
|
||||
}
|
||||
}
|
||||
|
||||
private getDefaultPreferencesEditor(accessor: ServicesAccessor): DefaultPreferencesEditor {
|
||||
private getPreferencesEditor(accessor: ServicesAccessor): PreferencesEditor {
|
||||
const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor();
|
||||
if (activeEditor instanceof SideBySideEditor) {
|
||||
const detailsEditor = activeEditor.getDetailsEditor();
|
||||
if (detailsEditor instanceof DefaultPreferencesEditor) {
|
||||
return detailsEditor;
|
||||
}
|
||||
if (activeEditor instanceof PreferencesEditor) {
|
||||
return activeEditor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
CommonEditorRegistry.registerEditorCommand(new StartSearchDefaultSettingsCommand({
|
||||
id: DEFAULT_EDITOR_COMMAND_FOCUS_SEARCH,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_DEFAULT_SETTINGS_EDITOR),
|
||||
id: SETTINGS_EDITOR_COMMAND_SEARCH,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR),
|
||||
kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.KEY_F }
|
||||
}));
|
|
@ -18,12 +18,11 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
|
|||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IPreferencesService, ISettingsGroup, ISetting, IPreferencesEditorModel, IFilterResult, CONTEXT_DEFAULT_SETTINGS_EDITOR, ISettingsEditorModel } from 'vs/workbench/parts/preferences/common/preferences';
|
||||
import { IPreferencesService, ISettingsGroup, ISetting, IPreferencesEditorModel, IFilterResult, ISettingsEditorModel } from 'vs/workbench/parts/preferences/common/preferences';
|
||||
import { SettingsEditorModel, DefaultSettingsEditorModel } from 'vs/workbench/parts/preferences/common/preferencesModels';
|
||||
import { ICodeEditor, IEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
|
||||
import { IContextMenuService, ContextSubMenu } from 'vs/platform/contextview/browser/contextView';
|
||||
import { SettingsGroupTitleWidget, EditPreferenceWidget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets';
|
||||
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { RangeHighlightDecorations } from 'vs/workbench/common/editor/rangeDecorations';
|
||||
import { IConfigurationEditingService } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
|
@ -190,8 +189,6 @@ export class WorkspaceSettingsRenderer extends UserSettingsRenderer implements I
|
|||
|
||||
export class DefaultSettingsRenderer extends Disposable implements IPreferencesRenderer<ISetting> {
|
||||
|
||||
private defaultSettingsEditorContextKey: IContextKey<boolean>;
|
||||
|
||||
private settingHighlighter: SettingHighlighter;
|
||||
private settingsGroupTitleRenderer: SettingsGroupTitleRenderer;
|
||||
private filteredMatchesRenderer: FilteredMatchesRenderer;
|
||||
|
@ -210,12 +207,10 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
|
|||
|
||||
constructor(protected editor: ICodeEditor, public readonly preferencesModel: DefaultSettingsEditorModel, private _associatedPreferencesModel: IPreferencesEditorModel<ISetting>,
|
||||
@IPreferencesService protected preferencesService: IPreferencesService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IInstantiationService protected instantiationService: IInstantiationService
|
||||
) {
|
||||
super();
|
||||
this.defaultSettingsEditorContextKey = CONTEXT_DEFAULT_SETTINGS_EDITOR.bindTo(contextKeyService);
|
||||
this.settingHighlighter = this._register(instantiationService.createInstance(SettingHighlighter, editor, this._onFocusPreference, this._onClearFocusPreference));
|
||||
this.settingsGroupTitleRenderer = this._register(instantiationService.createInstance(SettingsGroupTitleRenderer, editor));
|
||||
this.filteredMatchesRenderer = this._register(instantiationService.createInstance(FilteredMatchesRenderer, editor));
|
||||
|
@ -242,7 +237,6 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
|
|||
}
|
||||
|
||||
public render() {
|
||||
this.defaultSettingsEditorContextKey.set(true);
|
||||
this.settingsGroupTitleRenderer.render(this.preferencesModel.settingsGroups);
|
||||
this.editSettingActionRenderer.render(this.preferencesModel.settingsGroups, this._associatedPreferencesModel);
|
||||
this.hiddenAreasRenderer.render();
|
||||
|
@ -282,11 +276,6 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
|
|||
|
||||
public updatePreference(key: string, value: any, source: ISetting): void {
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.defaultSettingsEditorContextKey.set(false);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export interface HiddenAreasProvider {
|
||||
|
|
|
@ -80,6 +80,5 @@ export interface IPreferencesService {
|
|||
configureSettingsForLanguage(language: string): void;
|
||||
}
|
||||
|
||||
export const CONTEXT_DEFAULT_SETTINGS_EDITOR = new RawContextKey<boolean>('defaultSettingsEditor', false);
|
||||
export const DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL = 'defaultSettingsEditor.action.collapseAllGroups';
|
||||
export const DEFAULT_EDITOR_COMMAND_FOCUS_SEARCH = 'defaultSettings.action.focusSearch';
|
||||
export const CONTEXT_SETTINGS_EDITOR = new RawContextKey<boolean>('settingsEditor', false);
|
||||
export const SETTINGS_EDITOR_COMMAND_SEARCH = 'settings.action.search';
|
Loading…
Reference in a new issue