From 8a4bdea8b17fb0030aa1eec83404edef13f38e6e Mon Sep 17 00:00:00 2001 From: isidor Date: Mon, 20 Jun 2016 09:58:49 +0200 Subject: [PATCH] debug: polish loading and setting of x coordinate --- .../parts/debug/browser/debugActionsWidget.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts index 387a9149cb2..bdf2fced9f9 100644 --- a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts +++ b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts @@ -64,7 +64,6 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution { this.hide(); this.isBuilt = false; - this.onResize(); } private registerListeners(): void { @@ -82,7 +81,7 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution { this.telemetryService.publicLog('workbenchActionExecuted', { id: e.action.id, from: 'debugActionsWidget' }); } })); - $(window).on(dom.EventType.RESIZE, () => this.onResize(), this.toDispose); + $(window).on(dom.EventType.RESIZE, () => this.setXCoordinate(), this.toDispose); this.dragArea.on(dom.EventType.MOUSE_DOWN, event => { const $window = $(window); @@ -98,12 +97,14 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution { }); } - private onResize(): void { - const x = parseFloat(this.storageService.get(DEBUG_ACTIONS_WIDGET_POSITION_KEY, StorageScope.WORKSPACE, '0.5')) * window.innerWidth; - this.setXCoordinate(x); - } + private setXCoordinate(x?: number): void { + if (!this.isVisible) { + return; + } + if (!x) { + x = parseFloat(this.storageService.get(DEBUG_ACTIONS_WIDGET_POSITION_KEY, StorageScope.WORKSPACE, '0.5')) * window.innerWidth; + } - private setXCoordinate(x: number): void { const halfWidgetWidth = this.$el.getHTMLElement().clientWidth / 2; x = x + halfWidgetWidth - 16; // take into account half the size of the widget x = Math.max(148, x); // do not allow the widget to overflow on the left @@ -136,6 +137,7 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution { this.isVisible = true; this.$el.show(); + this.setXCoordinate(); } private hide(): void { -- GitLab