From 6093e46dfe62c7ecff96453d4dba719102226960 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Fri, 2 Dec 2016 11:34:16 +0100 Subject: [PATCH] Defaults Preferences Editor: Disable Find and Selection highlight Refactoring - Rename to Default preferences --- .../browser/preferences.contribution.ts | 8 +-- .../preferences/browser/preferencesEditor.ts | 66 +++++++------------ 2 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/vs/workbench/parts/preferences/browser/preferences.contribution.ts b/src/vs/workbench/parts/preferences/browser/preferences.contribution.ts index 1bc21c8cd6a..768492b4f34 100644 --- a/src/vs/workbench/parts/preferences/browser/preferences.contribution.ts +++ b/src/vs/workbench/parts/preferences/browser/preferences.contribution.ts @@ -13,7 +13,7 @@ import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/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 { PreferencesEditor, PreferencesEditorInput } from 'vs/workbench/parts/preferences/browser/preferencesEditor'; +import { DefaultPreferencesEditor, DefaultPreferencesEditorInput } from 'vs/workbench/parts/preferences/browser/preferencesEditor'; import { OpenGlobalSettingsAction, OpenGlobalKeybindingsAction, OpenWorkspaceSettingsAction } 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 { PreferencesService } from 'vs/workbench/parts/preferences/browser/preferencesService'; @@ -23,13 +23,13 @@ registerSingleton(IPreferencesService, PreferencesService); (Registry.as(EditorExtensions.Editors)).registerEditor( new EditorDescriptor( - PreferencesEditor.ID, + DefaultPreferencesEditor.ID, nls.localize('defaultPreferencesEditor', "Default Preferences Editor"), 'vs/workbench/parts/preferences/browser/preferencesEditor', - 'PreferencesEditor' + 'DefaultPreferencesEditor' ), [ - new SyncDescriptor(PreferencesEditorInput) + new SyncDescriptor(DefaultPreferencesEditorInput) ] ); diff --git a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts index e1f62e24efc..e64a0cbf64b 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts @@ -36,16 +36,16 @@ import { IContextKeyService, IContextKey, ContextKeyExpr } from 'vs/platform/con import { CommonEditorRegistry, EditorCommand } from 'vs/editor/common/editorCommonExtensions'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/workbench/services/themes/common/themeService'; -import { ICommandService } from 'vs/platform/commands/common/commands'; -import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; // Ignore following contributions import { FoldingController } from 'vs/editor/contrib/folding/browser/folding'; +import { FindController } from 'vs/editor/contrib/find/browser/find'; +import { SelectionHighlighter } from 'vs/editor/contrib/find/common/findController'; -export class PreferencesEditorInput extends EditorInput { +export class DefaultPreferencesEditorInput extends EditorInput { private _willDispose = new Emitter(); public willDispose: Event = this._willDispose.event; @@ -79,7 +79,7 @@ export class PreferencesEditorInput extends EditorInput { } matches(other: any): boolean { - if (!(other instanceof PreferencesEditorInput)) { + if (!(other instanceof DefaultPreferencesEditorInput)) { return false; } if (this._defaultPreferencesResource.fsPath !== other._defaultPreferencesResource.fsPath) { @@ -95,7 +95,7 @@ export class PreferencesEditorInput extends EditorInput { } } -export class PreferencesEditor extends BaseEditor { +export class DefaultPreferencesEditor extends BaseEditor { public static ID: string = 'workbench.editor.defaultPreferences'; private static VIEW_STATE: Map = new Map(); @@ -117,7 +117,7 @@ export class PreferencesEditor extends BaseEditor { @IModelService private modelService: IModelService, @IModeService private modeService: IModeService ) { - super(PreferencesEditor.ID, telemetryService); + super(DefaultPreferencesEditor.ID, telemetryService); this.delayedFilterLogging = new Delayer(1000); } @@ -126,7 +126,7 @@ export class PreferencesEditor extends BaseEditor { this.defaultSettingHeaderWidget = this._register(this.instantiationService.createInstance(DefaultSettingsHeaderWidget, parentContainer)); this._register(this.defaultSettingHeaderWidget.onDidChange(value => this.filterPreferences(value))); - this.defaultPreferencesEditor = this._register(this.instantiationService.createInstance(DefaultPreferencesEditor, parentContainer, this.getCodeEditorOptions())); + this.defaultPreferencesEditor = this._register(this.instantiationService.createInstance(DefaultPreferencesCodeEditor, parentContainer, this.getCodeEditorOptions())); const focusTracker = this._register(DOM.trackFocus(parentContainer)); focusTracker.addBlurListener(() => { this.isFocussed = false; }); } @@ -143,7 +143,7 @@ export class PreferencesEditor extends BaseEditor { fixedOverflowWidgets: true, readOnly: true }; - if (this.input && (this.input).isSettings) { + if (this.input && (this.input).isSettings) { options.lineNumbers = 'off'; options.renderLineHighlight = 'none'; options.scrollBeyondLastLine = false; @@ -154,7 +154,7 @@ export class PreferencesEditor extends BaseEditor { return options; } - setInput(input: PreferencesEditorInput, options: EditorOptions): TPromise { + setInput(input: DefaultPreferencesEditorInput, options: EditorOptions): TPromise { this.listenToInput(input); return super.setInput(input, options) .then(() => this.getOrCreateModel(input) @@ -162,7 +162,7 @@ export class PreferencesEditor extends BaseEditor { } public layout(dimension: Dimension) { - if (this.input && (this.input).isSettings) { + if (this.input && (this.input).isSettings) { const headerWidgetPosition = DOM.getDomNodePagePosition(this.defaultSettingHeaderWidget.domNode); this.defaultPreferencesEditor.layout({ height: dimension.height - headerWidgetPosition.height, @@ -176,14 +176,14 @@ export class PreferencesEditor extends BaseEditor { public focus(): void { this.isFocussed = true; - if (this.input && (this.input).isSettings) { + if (this.input && (this.input).isSettings) { this.defaultSettingHeaderWidget.focus(); } else { super.focus(); } } - private getOrCreateModel(input: PreferencesEditorInput): TPromise { + private getOrCreateModel(input: DefaultPreferencesEditorInput): TPromise { return this.preferencesService.createDefaultPreferencesEditorModel(input.getResource()) .then(preferencesEditorModel => { let model = this.modelService.getModel(input.getResource()); @@ -195,7 +195,7 @@ export class PreferencesEditor extends BaseEditor { }); } - private setDefaultPreferencesEditorInput(model: editorCommon.IModel, input: PreferencesEditorInput): void { + private setDefaultPreferencesEditorInput(model: editorCommon.IModel, input: DefaultPreferencesEditorInput): void { this.defaultPreferencesEditor.setModel(model); this.defaultPreferencesEditor.updateOptions(this.getCodeEditorOptions()); if (input.isSettings) { @@ -214,7 +214,7 @@ export class PreferencesEditor extends BaseEditor { public clearInput(): void { this.disposeModel(); - this.saveState(this.input); + this.saveState(this.input); if (this.inputDisposeListener) { this.inputDisposeListener.dispose(); } @@ -232,20 +232,20 @@ export class PreferencesEditor extends BaseEditor { } protected restoreViewState(input: EditorInput) { - const viewState = PreferencesEditor.VIEW_STATE.get((input).getResource()); + const viewState = DefaultPreferencesEditor.VIEW_STATE.get((input).getResource()); if (viewState) { this.getControl().restoreViewState(viewState); } } - private saveState(input: PreferencesEditorInput) { + private saveState(input: DefaultPreferencesEditorInput) { const state = this.getControl().saveViewState(); if (state) { const resource = input.getResource(); - if (PreferencesEditor.VIEW_STATE.has(resource)) { - PreferencesEditor.VIEW_STATE.delete(resource); + if (DefaultPreferencesEditor.VIEW_STATE.has(resource)) { + DefaultPreferencesEditor.VIEW_STATE.delete(resource); } - PreferencesEditor.VIEW_STATE.set(resource, state); + DefaultPreferencesEditor.VIEW_STATE.set(resource, state); } } @@ -253,8 +253,8 @@ export class PreferencesEditor extends BaseEditor { if (this.inputDisposeListener) { this.inputDisposeListener.dispose(); } - if (input instanceof PreferencesEditorInput) { - this.inputDisposeListener = (input).willDispose(() => this.saveState(input)); + if (input instanceof DefaultPreferencesEditorInput) { + this.inputDisposeListener = (input).willDispose(() => this.saveState(input)); } } @@ -272,30 +272,12 @@ export class PreferencesEditor extends BaseEditor { } } -class DefaultPreferencesEditor extends CodeEditor { - - constructor( - domElement: HTMLElement, - options: editorCommon.IEditorOptions, - @IInstantiationService instantiationService: IInstantiationService, - @ICodeEditorService codeEditorService: ICodeEditorService, - @ICommandService commandService: ICommandService, - @IContextKeyService contextKeyService: IContextKeyService - ) { - super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService); - } +class DefaultPreferencesCodeEditor extends CodeEditor { protected _getContributions(): IEditorContributionCtor[] { let contributions = super._getContributions(); - contributions = contributions.filter(c => { - if (c.prototype === FoldingController.prototype) { - return false; - } - // Find - // Ignore warnings - return true; - }); - return contributions; + let skipContributions = [FoldingController.prototype, SelectionHighlighter.prototype, FindController.prototype]; + return contributions.filter(c => skipContributions.indexOf(c.prototype) === -1); } } -- GitLab