Skip to content

Commit 86bf11f

Browse files
authored
debug: fix resizing window makes debug toolbar disappear (microsoft#209075)
Fixes microsoft#208895 Should work but testing on aux windows was limited due to microsoft#209073
1 parent 72250a8 commit 86bf11f

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/vs/workbench/contrib/debug/browser/debugToolBar.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
5353
private activeActions: IAction[];
5454
private updateScheduler: RunOnceScheduler;
5555
private debugToolBarMenu: IMenu;
56-
private yCoordinate = 0;
5756

5857
private isVisible = false;
5958
private isBuilt = false;
@@ -141,7 +140,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
141140
}
142141
if (e.affectsConfiguration(LayoutSettings.EDITOR_TABS_MODE) || e.affectsConfiguration(LayoutSettings.COMMAND_CENTER)) {
143142
this._yRange = undefined;
144-
this.setYCoordinate();
143+
this.setCoordinates();
145144
}
146145
}));
147146
this._register(this.debugToolBarMenu.onDidChange(() => this.updateScheduler.schedule()));
@@ -187,9 +186,14 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
187186
});
188187
}));
189188

190-
this._register(this.layoutService.onDidChangePartVisibility(() => this.setYCoordinate()));
189+
this._register(this.layoutService.onDidChangePartVisibility(() => this.setCoordinates()));
191190

192191
const resizeListener = this._register(new MutableDisposable());
192+
const registerResizeListener = () => {
193+
resizeListener.value = this._register(dom.addDisposableListener(
194+
dom.getWindow(this.layoutService.activeContainer), dom.EventType.RESIZE, () => this.setCoordinates())
195+
);
196+
};
193197

194198
this._register(this.layoutService.onDidChangeActiveContainer(async () => {
195199
this._yRange = undefined;
@@ -202,21 +206,24 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
202206
this.setCoordinates();
203207
}
204208

205-
resizeListener.value = this._register(dom.addDisposableListener(
206-
dom.getWindow(this.layoutService.activeContainer), dom.EventType.RESIZE, () => this.setYCoordinate()));
209+
registerResizeListener();
207210
}));
211+
212+
registerResizeListener();
208213
}
209214

210215
private storePosition(): void {
211216
const activeWindow = dom.getWindow(this.layoutService.activeContainer);
212217
const isMainWindow = this.layoutService.activeContainer === this.layoutService.mainContainer;
213218

214-
const left = this.$el.getBoundingClientRect().left / activeWindow.innerWidth;
219+
const rect = this.$el.getBoundingClientRect();
220+
const y = rect.top;
221+
const x = rect.left / activeWindow.innerWidth;
215222
if (isMainWindow) {
216-
this.storageService.store(DEBUG_TOOLBAR_POSITION_KEY, left, StorageScope.PROFILE, StorageTarget.MACHINE);
217-
this.storageService.store(DEBUG_TOOLBAR_Y_KEY, this.yCoordinate, StorageScope.PROFILE, StorageTarget.MACHINE);
223+
this.storageService.store(DEBUG_TOOLBAR_POSITION_KEY, x, StorageScope.PROFILE, StorageTarget.MACHINE);
224+
this.storageService.store(DEBUG_TOOLBAR_Y_KEY, y, StorageScope.PROFILE, StorageTarget.MACHINE);
218225
} else {
219-
this.auxWindowCoordinates.set(activeWindow, { x: left, y: this.yCoordinate });
226+
this.auxWindowCoordinates.set(activeWindow, { x, y });
220227
}
221228
}
222229

@@ -271,11 +278,10 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
271278
this.setYCoordinate(y ?? this.yDefault);
272279
}
273280

274-
private setYCoordinate(y = this.yCoordinate): void {
281+
private setYCoordinate(y: number): void {
275282
const [yMin, yMax] = this.yRange;
276283
y = Math.max(yMin, Math.min(y, yMax));
277284
this.$el.style.top = `${y}px`;
278-
this.yCoordinate = y;
279285
}
280286

281287
private get yDefault() {
@@ -322,7 +328,9 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
322328

323329
private doShowInActiveContainer(): void {
324330
this.layoutService.activeContainer.appendChild(this.$el);
325-
this.trackPixelRatioListener.value = PixelRatio.getInstance(dom.getWindow(this.$el)).onDidChange(() => this.setYCoordinate());
331+
this.trackPixelRatioListener.value = PixelRatio.getInstance(dom.getWindow(this.$el)).onDidChange(
332+
() => this.setCoordinates()
333+
);
326334
}
327335

328336
private hide(): void {

0 commit comments

Comments
 (0)