diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index f772cae81ac6c0260ecde6c0655280d891383e11..b919461e4f3b3dc0e55c897e1e611fcc89b47cbf 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -40,7 +40,6 @@ export class StatusbarPart extends Part implements IStatusbarService { private static PRIORITY_PROP = 'priority'; private static ALIGNMENT_PROP = 'alignment'; - private toDispose: IDisposable[]; private statusItemsContainer: Builder; private statusMsgDispose: IDisposable; @@ -52,7 +51,11 @@ export class StatusbarPart extends Part implements IStatusbarService { ) { super(id, { hasTitle: false }, themeService); - this.toDispose = []; + this.registerListeners(); + } + + private registerListeners(): void { + this.toUnbind.push(this.contextService.onDidChangeWorkspaceRoots(() => this.updateStyles())); } public addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number = 0): IDisposable { @@ -120,7 +123,7 @@ export class StatusbarPart extends Part implements IStatusbarService { const descriptors = rightDescriptors.concat(leftDescriptors); // right first because they float - this.toDispose.push(...descriptors.map(descriptor => { + this.toUnbind.push(...descriptors.map(descriptor => { const item = this.instantiationService.createInstance(descriptor.syncDescriptor); const el = this.doCreateStatusItem(descriptor.alignment, descriptor.priority); @@ -200,12 +203,6 @@ export class StatusbarPart extends Part implements IStatusbarService { return dispose; } - - public dispose(): void { - this.toDispose = dispose(this.toDispose); - - super.dispose(); - } } let manageExtensionAction: ManageExtensionAction; diff --git a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts index 44b9db45be34c8aae4a1180ded73d194310d2ad6..78aefdb3d52927932dde93a10145a8c4e174956b 100644 --- a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts +++ b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/css!vs/workbench/parts/debug/browser/media/debugActionsWidget'; -import * as lifecycle from 'vs/base/common/lifecycle'; import * as errors from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; import * as browser from 'vs/base/browser/browser'; @@ -45,7 +44,6 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi private $el: builder.Builder; private dragArea: builder.Builder; - private toDispose: lifecycle.IDisposable[]; private actionBar: ActionBar; private allActions: AbstractDebugAction[]; private activeActions: AbstractDebugAction[]; @@ -72,7 +70,6 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi const actionBarContainter = $().div().addClass('.action-bar-container'); this.$el.append(actionBarContainter); - this.toDispose = []; this.activeActions = []; this.actionBar = new ActionBar(actionBarContainter, { orientation: ActionsOrientation.HORIZONTAL, @@ -87,7 +84,7 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi this.updateStyles(); - this.toDispose.push(this.actionBar); + this.toUnbind.push(this.actionBar); this.registerListeners(); this.hide(); @@ -95,9 +92,9 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi } private registerListeners(): void { - this.toDispose.push(this.debugService.onDidChangeState(state => this.update(state))); - this.toDispose.push(this.configurationService.onDidUpdateConfiguration(() => this.update(this.debugService.state))); - this.toDispose.push(this.actionBar.actionRunner.addListener(EventType.RUN, (e: any) => { + this.toUnbind.push(this.debugService.onDidChangeState(state => this.update(state))); + this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(() => this.update(this.debugService.state))); + this.toUnbind.push(this.actionBar.actionRunner.addListener(EventType.RUN, (e: any) => { // check for error if (e.error && !errors.isPromiseCanceledError(e.error)) { this.messageService.show(severity.Error, e.error); @@ -108,7 +105,7 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi this.telemetryService.publicLog('workbenchActionExecuted', { id: e.action.id, from: 'debugActionsWidget' }); } })); - $(window).on(dom.EventType.RESIZE, () => this.setXCoordinate(), this.toDispose); + $(window).on(dom.EventType.RESIZE, () => this.setXCoordinate(), this.toUnbind); this.dragArea.on(dom.EventType.MOUSE_UP, (event: MouseEvent) => { const mouseClickEvent = new StandardMouseEvent(event); @@ -137,8 +134,8 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi }); }); - this.toDispose.push(this.partService.onTitleBarVisibilityChange(() => this.positionDebugWidget())); - this.toDispose.push(browser.onDidChangeZoomLevel(() => this.positionDebugWidget())); + this.toUnbind.push(this.partService.onTitleBarVisibilityChange(() => this.positionDebugWidget())); + this.toUnbind.push(browser.onDidChangeZoomLevel(() => this.positionDebugWidget())); } private storePosition(): void { @@ -235,7 +232,7 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi this.allActions.push(this.instantiationService.createInstance(ReverseContinueAction, ReverseContinueAction.ID, ReverseContinueAction.LABEL)); this.allActions.push(this.instantiationService.createInstance(FocusProcessAction, FocusProcessAction.ID, FocusProcessAction.LABEL)); this.allActions.forEach(a => { - this.toDispose.push(a); + this.toUnbind.push(a); }); } @@ -271,7 +268,7 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi } public dispose(): void { - this.toDispose = lifecycle.dispose(this.toDispose); + super.dispose(); if (this.$el) { this.$el.destroy(); diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 5823a900518f4b6b0d7ae142eed7afbe514a5bd2..b097d3a3652da5d44e7c8546755e2396e27cd37a 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -9,7 +9,6 @@ import uri from 'vs/base/common/uri'; import { wireCancellationToken } from 'vs/base/common/async'; import { TPromise } from 'vs/base/common/winjs.base'; import * as errors from 'vs/base/common/errors'; -import * as lifecycle from 'vs/base/common/lifecycle'; import { IAction } from 'vs/base/common/actions'; import { Dimension, Builder } from 'vs/base/browser/builder'; import * as dom from 'vs/base/browser/dom'; @@ -73,7 +72,6 @@ export class Repl extends Panel implements IPrivateReplService { private static REPL_INPUT_INITIAL_HEIGHT = 19; private static REPL_INPUT_MAX_HEIGHT = 170; - private toDispose: lifecycle.IDisposable[]; private tree: ITree; private renderer: ReplExpressionsRenderer; private characterWidthSurveyor: HTMLElement; @@ -99,15 +97,14 @@ export class Repl extends Panel implements IPrivateReplService { super(debug.REPL_ID, telemetryService, themeService); this.replInputHeight = Repl.REPL_INPUT_INITIAL_HEIGHT; - this.toDispose = []; this.registerListeners(); } private registerListeners(): void { - this.toDispose.push(this.debugService.getModel().onDidChangeReplElements(() => { + this.toUnbind.push(this.debugService.getModel().onDidChangeReplElements(() => { this.refreshReplElements(this.debugService.getModel().getReplElements().length === 0); })); - this.toDispose.push(this.panelService.onDidPanelOpen(panel => this.refreshReplElements(true))); + this.toUnbind.push(this.panelService.onDidPanelOpen(panel => this.refreshReplElements(true))); } private refreshReplElements(noDelay: boolean): void { @@ -154,8 +151,8 @@ export class Repl extends Panel implements IPrivateReplService { controller }, replTreeOptions); - this.toDispose.push(attachListStyler(this.tree, this.themeService)); - this.toDispose.push(this.listService.register(this.tree)); + this.toUnbind.push(attachListStyler(this.tree, this.themeService)); + this.toUnbind.push(this.listService.register(this.tree)); if (!Repl.HISTORY) { Repl.HISTORY = new ReplHistory(JSON.parse(this.storageService.get(HISTORY_STORAGE_KEY, StorageScope.WORKSPACE, '[]'))); @@ -168,7 +165,7 @@ export class Repl extends Panel implements IPrivateReplService { this.replInputContainer = dom.append(container, $('.repl-input-wrapper')); const scopedContextKeyService = this.contextKeyService.createScoped(this.replInputContainer); - this.toDispose.push(scopedContextKeyService); + this.toUnbind.push(scopedContextKeyService); debug.CONTEXT_IN_DEBUG_REPL.bindTo(scopedContextKeyService).set(true); const onFirstReplLine = debug.CONTEXT_ON_FIRST_DEBUG_REPL_LINE.bindTo(scopedContextKeyService); onFirstReplLine.set(true); @@ -197,20 +194,20 @@ export class Repl extends Panel implements IPrivateReplService { } }); - this.toDispose.push(this.replInput.onDidScrollChange(e => { + this.toUnbind.push(this.replInput.onDidScrollChange(e => { if (!e.scrollHeightChanged) { return; } this.replInputHeight = Math.max(Repl.REPL_INPUT_INITIAL_HEIGHT, Math.min(Repl.REPL_INPUT_MAX_HEIGHT, e.scrollHeight, this.dimension.height)); this.layout(this.dimension); })); - this.toDispose.push(this.replInput.onDidChangeCursorPosition(e => { + this.toUnbind.push(this.replInput.onDidChangeCursorPosition(e => { onFirstReplLine.set(e.position.lineNumber === 1); onLastReplLine.set(e.position.lineNumber === this.replInput.getModel().getLineCount()); })); - this.toDispose.push(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.FOCUS, () => dom.addClass(this.replInputContainer, 'synthetic-focus'))); - this.toDispose.push(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.BLUR, () => dom.removeClass(this.replInputContainer, 'synthetic-focus'))); + this.toUnbind.push(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.FOCUS, () => dom.addClass(this.replInputContainer, 'synthetic-focus'))); + this.toUnbind.push(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.BLUR, () => dom.removeClass(this.replInputContainer, 'synthetic-focus'))); } public navigateHistory(previous: boolean): void { @@ -270,7 +267,7 @@ export class Repl extends Panel implements IPrivateReplService { ]; this.actions.forEach(a => { - this.toDispose.push(a); + this.toUnbind.push(a); }); } @@ -311,7 +308,6 @@ export class Repl extends Panel implements IPrivateReplService { public dispose(): void { this.replInput.dispose(); - this.toDispose = lifecycle.dispose(this.toDispose); super.dispose(); } } diff --git a/src/vs/workbench/parts/debug/electron-browser/statusbarColorProvider.ts b/src/vs/workbench/parts/debug/electron-browser/statusbarColorProvider.ts index beabb4b0ef3d61c66ceb4414dfd6e9a57f3b4dd4..f5c8e2040ce6e0049571d3a1f7b08809379b8b51 100644 --- a/src/vs/workbench/parts/debug/electron-browser/statusbarColorProvider.ts +++ b/src/vs/workbench/parts/debug/electron-browser/statusbarColorProvider.ts @@ -48,11 +48,8 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri } private registerListeners(): void { - this.toUnbind.push(this.debugService.onDidChangeState(state => this.onDidChangeState(state))); - } - - private onDidChangeState(state: State): void { - this.updateStyles(); + this.toUnbind.push(this.debugService.onDidChangeState(state => this.updateStyles())); + this.toUnbind.push(this.contextService.onDidChangeWorkspaceRoots(state => this.updateStyles())); } protected updateStyles(): void { diff --git a/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts b/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts index b124264626e57ff6ac175887a717c167b81180fe..7a93025af9dcb7d83334e1dbfaa07f6b245b7982 100644 --- a/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts +++ b/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts @@ -58,6 +58,12 @@ export class FeedbackStatusbarItem extends Themable implements IStatusbarItem { @IThemeService themeService: IThemeService ) { super(themeService); + + this.registerListeners(); + } + + private registerListeners(): void { + this.toUnbind.push(this.contextService.onDidChangeWorkspaceRoots(() => this.updateStyles())); } protected updateStyles(): void { diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index a8b5c24217feef6d89b3aa2ff05dfd85542388c6..00bed9ea2fdba8b374463dcef29bcb349d34771d 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -10,7 +10,6 @@ import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { Delayer } from 'vs/base/common/async'; import dom = require('vs/base/browser/dom'); -import lifecycle = require('vs/base/common/lifecycle'); import builder = require('vs/base/browser/builder'); import { IAction, Action } from 'vs/base/common/actions'; import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; @@ -44,7 +43,6 @@ export class MarkersPanel extends Panel { public markersModel: MarkersModel; - private toDispose: lifecycle.IDisposable[]; private delayedRefresh: Delayer; private lastSelectedRelativeTop: number = 0; @@ -78,7 +76,6 @@ export class MarkersPanel extends Panel { @IThemeService themeService: IThemeService ) { super(Constants.MARKERS_PANEL_ID, telemetryService, themeService); - this.toDispose = []; this.delayedRefresh = new Delayer(500); this.autoExpanded = new Set(); this.markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(contextKeyService); @@ -89,7 +86,7 @@ export class MarkersPanel extends Panel { this.markersModel = new MarkersModel(); this.rangeHighlightDecorations = this.instantiationService.createInstance(RangeHighlightDecorations); - this.toDispose.push(this.rangeHighlightDecorations); + this.toUnbind.push(this.rangeHighlightDecorations); dom.addClass(parent.getHTMLElement(), 'markers-panel'); @@ -233,7 +230,7 @@ export class MarkersPanel extends Panel { this.markerFocusContextKey.set(false); }); - this.toDispose.push(this.listService.register(this.tree)); + this.toUnbind.push(this.listService.register(this.tree)); } private createActions(): void { @@ -244,15 +241,15 @@ export class MarkersPanel extends Panel { this.collapseAllAction ]; this.actions.forEach(a => { - this.toDispose.push(a); + this.toUnbind.push(a); }); } private createListeners(): void { - this.toDispose.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationsUpdated(this.configurationService.getConfiguration()))); - this.toDispose.push(this.markerService.onMarkerChanged(this.onMarkerChanged, this)); - this.toDispose.push(this.editorGroupService.onEditorsChanged(this.onEditorsChanged, this)); - this.toDispose.push(this.tree.addListener('selection', () => this.onSelected())); + this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(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())); } private onMarkerChanged(changedResources: URI[]) { @@ -409,10 +406,10 @@ export class MarkersPanel extends Panel { } public dispose(): void { + super.dispose(); + this.delayedRefresh.cancel(); - this.toDispose = lifecycle.dispose(this.toDispose); this.tree.dispose(); this.markersModel.dispose(); - super.dispose(); } } \ No newline at end of file diff --git a/src/vs/workbench/parts/output/browser/outputPanel.ts b/src/vs/workbench/parts/output/browser/outputPanel.ts index 42b8505f6349a9ddf6b1fcb987d1c519e197421f..811e8d69a059436022c398a70de7e6313f1b1488 100644 --- a/src/vs/workbench/parts/output/browser/outputPanel.ts +++ b/src/vs/workbench/parts/output/browser/outputPanel.ts @@ -5,7 +5,6 @@ import 'vs/css!./media/output'; import nls = require('vs/nls'); -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; import { Action, IAction } from 'vs/base/common/actions'; import { Builder } from 'vs/base/browser/builder'; @@ -27,7 +26,6 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; export class OutputPanel extends TextResourceEditor { - private toDispose: IDisposable[]; private actions: IAction[]; private scopedInstantiationService: IInstantiationService; @@ -46,7 +44,6 @@ export class OutputPanel extends TextResourceEditor { super(telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, modeService, textFileService); this.scopedInstantiationService = instantiationService; - this.toDispose = []; } public getId(): string { @@ -62,7 +59,7 @@ export class OutputPanel extends TextResourceEditor { ]; this.actions.forEach(a => { - this.toDispose.push(a); + this.toUnbind.push(a); }); } @@ -111,7 +108,7 @@ export class OutputPanel extends TextResourceEditor { // First create the scoped instantation service and only then construct the editor using the scoped service const scopedContextKeyService = this.contextKeyService.createScoped(parent.getHTMLElement()); - this.toDispose.push(scopedContextKeyService); + this.toUnbind.push(scopedContextKeyService); this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, scopedContextKeyService])); super.createEditor(parent); @@ -122,10 +119,4 @@ export class OutputPanel extends TextResourceEditor { public get instantiationService(): IInstantiationService { return this.scopedInstantiationService; } - - public dispose(): void { - this.toDispose = dispose(this.toDispose); - - super.dispose(); - } } diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index a4aae6fe924eb0bdaa586576aaa93e4dd4b0728f..bff93d5f19a228213cc6b29b61347c1c442ee871 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -69,7 +69,6 @@ export class SearchViewlet extends Viewlet { private static SHOW_REPLACE_STORAGE_KEY = 'vs.search.show.replace'; private isDisposed: boolean; - private toDispose: lifecycle.IDisposable[]; private loading: boolean; private queryBuilder: QueryBuilder; @@ -126,7 +125,6 @@ export class SearchViewlet extends Viewlet { ) { super(Constants.VIEWLET_ID, telemetryService, themeService); - this.toDispose = []; this.viewletVisible = Constants.SearchViewletVisibleKey.bindTo(contextKeyService); this.inputBoxFocused = Constants.InputBoxFocusedKey.bindTo(this.contextKeyService); this.inputPatternIncludesFocused = Constants.PatternIncludesFocusedKey.bindTo(this.contextKeyService); @@ -483,7 +481,7 @@ export class SearchViewlet extends Viewlet { keyboardSupport: false }); - this.toDispose.push(attachListStyler(this.tree, this.themeService)); + this.toUnbind.push(attachListStyler(this.tree, this.themeService)); this.tree.setInput(this.viewModel.searchResult); this.toUnbind.push(renderer); @@ -1427,8 +1425,6 @@ export class SearchViewlet extends Viewlet { public dispose(): void { this.isDisposed = true; - this.toDispose = lifecycle.dispose(this.toDispose); - if (this.tree) { this.tree.dispose(); } diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index 91b5d563fc83a1895ff39b2b446df4feea1fedbd..35e0f9bf11f307965dfb6a8027643d7391f0e46e 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -283,6 +283,12 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { this.activeCount = 0; this.icons = []; + + this.registerListeners(); + } + + private registerListeners(): void { + this.toUnbind.push(this.contextService.onDidChangeWorkspaceRoots(() => this.updateStyles())); } protected updateStyles(): void {