From b4fdeadbb801663c5631bf156f2475f7bcfeaf9f Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Wed, 18 Oct 2017 17:59:22 +0200 Subject: [PATCH] Adopt new configuration change event in markers and preferences areas --- .../parts/markers/browser/markersPanel.ts | 15 +++------------ .../preferences/browser/preferencesRenderers.ts | 10 ++++++++-- .../preferences/common/preferencesContribution.ts | 6 +++++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index 13305518c4e..5c811c3b975 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -19,7 +19,7 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer import { Panel } from 'vs/workbench/browser/panel'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import Constants from 'vs/workbench/parts/markers/common/constants'; -import { IProblemsConfiguration, MarkersModel, Marker, Resource, FilterOptions } from 'vs/workbench/parts/markers/common/markersModel'; +import { MarkersModel, Marker, Resource, FilterOptions } from 'vs/workbench/parts/markers/common/markersModel'; import { Controller } from 'vs/workbench/parts/markers/browser/markersTreeController'; import Tree = require('vs/base/parts/tree/browser/tree'); import TreeImpl = require('vs/base/parts/tree/browser/treeImpl'); @@ -47,7 +47,6 @@ export class MarkersPanel extends Panel { private lastSelectedRelativeTop: number = 0; private currentActiveResource: URI = null; - private hasToAutoReveal: boolean; private tree: Tree.ITree; private autoExpanded: Set; @@ -90,9 +89,6 @@ export class MarkersPanel extends Panel { dom.addClass(parent.getHTMLElement(), 'markers-panel'); - const conf = this.configurationService.getConfiguration(); - this.onConfigurationsUpdated(conf); - let container = dom.append(parent.getHTMLElement(), dom.$('.markers-panel-container')); this.createMessageBox(container); @@ -253,7 +249,6 @@ export class MarkersPanel extends Panel { } private createListeners(): void { - this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationsUpdated(this.configurationService.getConfiguration()))); this.toUnbind.push(this.markerService.onMarkerChanged(this.onMarkerChanged, this)); this.toUnbind.push(this.editorGroupService.onEditorsChanged(this.onEditorsChanged, this)); this.toUnbind.push(this.tree.addListener('selection', () => this.onSelected())); @@ -289,10 +284,6 @@ export class MarkersPanel extends Panel { this.autoReveal(); } - private onConfigurationsUpdated(conf: IProblemsConfiguration): void { - this.hasToAutoReveal = conf && conf.problems && conf.problems.autoReveal; - } - private onSelected(): void { let selection = this.tree.getSelection(); if (selection && selection.length > 0) { @@ -338,8 +329,8 @@ export class MarkersPanel extends Panel { } private autoReveal(focus: boolean = false): void { - let conf = this.configurationService.getConfiguration(); - if (conf && conf.problems && conf.problems.autoReveal) { + let autoReveal = this.configurationService.getValue('problems.autoReveal'); + if (typeof autoReveal === 'boolean' && autoReveal) { this.revealMarkersForCurrentActiveEditor(focus); } } diff --git a/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts b/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts index 151446902f8..08edba32488 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts @@ -31,7 +31,7 @@ import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorE import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { MarkdownString } from 'vs/base/common/htmlContent'; -import { overrideIdentifierFromKey, IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; +import { overrideIdentifierFromKey, IConfigurationService, ConfigurationTarget, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; export interface IPreferencesRenderer extends IDisposable { preferencesModel: IPreferencesEditorModel; @@ -950,7 +950,7 @@ class UnsupportedWorkspaceSettingsRenderer extends Disposable { @IMarkerService private markerService: IMarkerService ) { super(); - this._register(this.configurationService.onDidChangeConfiguration(() => this.render())); + this._register(this.configurationService.onDidChangeConfiguration(e => this.onDidConfigurationChange(e))); } private getMarkerMessage(settingKey: string): string { @@ -987,6 +987,12 @@ class UnsupportedWorkspaceSettingsRenderer extends Disposable { } } + private onDidConfigurationChange(event: IConfigurationChangeEvent): void { + if (event.source === ConfigurationTarget.DEFAULT || event.source === ConfigurationTarget.WORKSPACE || event.source === ConfigurationTarget.WORKSPACE_FOLDER) { + this.render(); + } + } + public dispose(): void { this.markerService.remove('preferencesEditor', [this.workspaceSettingsEditorModel.uri]); super.dispose(); diff --git a/src/vs/workbench/parts/preferences/common/preferencesContribution.ts b/src/vs/workbench/parts/preferences/common/preferencesContribution.ts index db5b54b3fb7..f93a4021f38 100644 --- a/src/vs/workbench/parts/preferences/common/preferencesContribution.ts +++ b/src/vs/workbench/parts/preferences/common/preferencesContribution.ts @@ -38,7 +38,11 @@ export class PreferencesContribution implements IWorkbenchContribution { @IWorkspaceContextService private workspaceService: IWorkspaceContextService, @IConfigurationService private configurationService: IConfigurationService ) { - this.settingsListener = this.configurationService.onDidChangeConfiguration(() => this.handleSettingsEditorOverride()); + this.settingsListener = this.configurationService.onDidChangeConfiguration(e => { + if (e.affectsConfiguration(DEFAULT_SETTINGS_EDITOR_SETTING)) { + this.handleSettingsEditorOverride(); + } + }); this.handleSettingsEditorOverride(); this.start(); -- GitLab