Prevent overriding of Disposable.dispose
A common mistake made was overriding dispose and not calling super.dispose, so a TS trick is now used to move it to a readonly property instead of a member method which prevents it being overridden.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { ColorZoneStore, IColorZone, IColorZoneStore } from 'browser/decorations/ColorZoneStore';
|
||||
import { addDisposableDomListener } from 'browser/Lifecycle';
|
||||
import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||
|
||||
// Helper objects to avoid excessive calculation and garbage collection during rendering. These are
|
||||
@@ -68,6 +68,9 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
this._registerDecorationListeners();
|
||||
this._registerBufferChangeListeners();
|
||||
this._registerDimensionChangeListeners();
|
||||
this.register(toDisposable(() => {
|
||||
this._canvas?.remove();
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,11 +123,6 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
this._queueRefresh(true);
|
||||
}
|
||||
|
||||
public override dispose(): void {
|
||||
this._canvas?.remove();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private _refreshDrawConstants(): void {
|
||||
// width
|
||||
const outerWidth = Math.floor(this._canvas.width / 3);
|
||||
|
||||
Reference in New Issue
Block a user