@@ -53,7 +53,6 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
53
53
private activeActions : IAction [ ] ;
54
54
private updateScheduler : RunOnceScheduler ;
55
55
private debugToolBarMenu : IMenu ;
56
- private yCoordinate = 0 ;
57
56
58
57
private isVisible = false ;
59
58
private isBuilt = false ;
@@ -141,7 +140,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
141
140
}
142
141
if ( e . affectsConfiguration ( LayoutSettings . EDITOR_TABS_MODE ) || e . affectsConfiguration ( LayoutSettings . COMMAND_CENTER ) ) {
143
142
this . _yRange = undefined ;
144
- this . setYCoordinate ( ) ;
143
+ this . setCoordinates ( ) ;
145
144
}
146
145
} ) ) ;
147
146
this . _register ( this . debugToolBarMenu . onDidChange ( ( ) => this . updateScheduler . schedule ( ) ) ) ;
@@ -187,9 +186,14 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
187
186
} ) ;
188
187
} ) ) ;
189
188
190
- this . _register ( this . layoutService . onDidChangePartVisibility ( ( ) => this . setYCoordinate ( ) ) ) ;
189
+ this . _register ( this . layoutService . onDidChangePartVisibility ( ( ) => this . setCoordinates ( ) ) ) ;
191
190
192
191
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
+ } ;
193
197
194
198
this . _register ( this . layoutService . onDidChangeActiveContainer ( async ( ) => {
195
199
this . _yRange = undefined ;
@@ -202,21 +206,24 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
202
206
this . setCoordinates ( ) ;
203
207
}
204
208
205
- resizeListener . value = this . _register ( dom . addDisposableListener (
206
- dom . getWindow ( this . layoutService . activeContainer ) , dom . EventType . RESIZE , ( ) => this . setYCoordinate ( ) ) ) ;
209
+ registerResizeListener ( ) ;
207
210
} ) ) ;
211
+
212
+ registerResizeListener ( ) ;
208
213
}
209
214
210
215
private storePosition ( ) : void {
211
216
const activeWindow = dom . getWindow ( this . layoutService . activeContainer ) ;
212
217
const isMainWindow = this . layoutService . activeContainer === this . layoutService . mainContainer ;
213
218
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 ;
215
222
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 ) ;
218
225
} else {
219
- this . auxWindowCoordinates . set ( activeWindow , { x : left , y : this . yCoordinate } ) ;
226
+ this . auxWindowCoordinates . set ( activeWindow , { x, y } ) ;
220
227
}
221
228
}
222
229
@@ -271,11 +278,10 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
271
278
this . setYCoordinate ( y ?? this . yDefault ) ;
272
279
}
273
280
274
- private setYCoordinate ( y = this . yCoordinate ) : void {
281
+ private setYCoordinate ( y : number ) : void {
275
282
const [ yMin , yMax ] = this . yRange ;
276
283
y = Math . max ( yMin , Math . min ( y , yMax ) ) ;
277
284
this . $el . style . top = `${ y } px` ;
278
- this . yCoordinate = y ;
279
285
}
280
286
281
287
private get yDefault ( ) {
@@ -322,7 +328,9 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
322
328
323
329
private doShowInActiveContainer ( ) : void {
324
330
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
+ ) ;
326
334
}
327
335
328
336
private hide ( ) : void {
0 commit comments