Skip to content

Commit 62ce318

Browse files
authored
Merge pull request #5827 from Tyriar/or_lifecycle
Improve overview ruler lifecycle
2 parents 34e0179 + 08ae141 commit 62ce318

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/browser/decorations/OverviewRulerRenderer.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ export class OverviewRulerRenderer extends Disposable {
9494
this._register(this._coreBrowserService.onDprChange(() => this._queueRefresh(true)));
9595
this._register(this._optionsService.onSpecificOptionChange('scrollbar', () => this._queueRefresh(true)));
9696
this._register(this._themeService.onChangeColors(() => this._queueRefresh()));
97+
this._register(toDisposable(() => {
98+
if (this._animationFrame !== undefined) {
99+
this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame);
100+
this._animationFrame = undefined;
101+
}
102+
}));
97103
this._queueRefresh(true);
98104
}
99105

@@ -136,6 +142,9 @@ export class OverviewRulerRenderer extends Disposable {
136142
}
137143

138144
private _refreshCanvasDimensions(): void {
145+
if (this._store.isDisposed || !this._renderService.hasRenderer()) {
146+
return;
147+
}
139148
const cssCanvasHeight = this._renderService.dimensions.css.canvas.height;
140149
const deviceCanvasHeight = this._renderService.dimensions.device.canvas.height;
141150
this._canvas.style.width = `${this._width}px`;
@@ -147,6 +156,9 @@ export class OverviewRulerRenderer extends Disposable {
147156
}
148157

149158
private _refreshDecorations(): void {
159+
if (this._store.isDisposed || !this._renderService.hasRenderer()) {
160+
return;
161+
}
150162
if (this._shouldUpdateDimensions) {
151163
this._refreshCanvasDimensions();
152164
}
@@ -200,13 +212,18 @@ export class OverviewRulerRenderer extends Disposable {
200212
}
201213

202214
private _queueRefresh(updateCanvasDimensions?: boolean, updateAnchor?: boolean): void {
215+
if (this._store.isDisposed) {
216+
return;
217+
}
203218
this._shouldUpdateDimensions = updateCanvasDimensions || this._shouldUpdateDimensions;
204219
this._shouldUpdateAnchor = updateAnchor || this._shouldUpdateAnchor;
205220
if (this._animationFrame !== undefined) {
206221
return;
207222
}
208223
this._animationFrame = this._coreBrowserService.window.requestAnimationFrame(() => {
209-
this._refreshDecorations();
224+
if (!this._store.isDisposed) {
225+
this._refreshDecorations();
226+
}
210227
this._animationFrame = undefined;
211228
});
212229
}

0 commit comments

Comments
 (0)