Use disposal registration
This commit is contained in:
@@ -55,10 +55,8 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override dispose(): void {
|
public override dispose(): void {
|
||||||
if (this._cursorBlinkStateManager) {
|
this._cursorBlinkStateManager?.dispose();
|
||||||
this._cursorBlinkStateManager.dispose();
|
this._cursorBlinkStateManager = undefined;
|
||||||
this._cursorBlinkStateManager = undefined;
|
|
||||||
}
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, IMouseZoneManager, IMouseZone, IRegisteredLinkMatcher } from 'browser/Types';
|
import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, IMouseZoneManager, IMouseZone, IRegisteredLinkMatcher } from 'browser/Types';
|
||||||
import { IBufferStringIteratorResult } from 'common/buffer/Types';
|
import { IBufferStringIteratorResult } from 'common/buffer/Types';
|
||||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||||
|
import { Disposable } from 'common/Lifecycle';
|
||||||
import { ILogService, IBufferService, IOptionsService, IUnicodeService } from 'common/services/Services';
|
import { ILogService, IBufferService, IOptionsService, IUnicodeService } from 'common/services/Services';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +19,7 @@ const OVERSCAN_CHAR_LIMIT = 2000;
|
|||||||
/**
|
/**
|
||||||
* The Linkifier applies links to rows shortly after they have been refreshed.
|
* The Linkifier applies links to rows shortly after they have been refreshed.
|
||||||
*/
|
*/
|
||||||
export class Linkifier implements ILinkifier {
|
export class Linkifier extends Disposable implements ILinkifier {
|
||||||
/**
|
/**
|
||||||
* The time to wait after a row is changed before it is linkified. This prevents
|
* The time to wait after a row is changed before it is linkified. This prevents
|
||||||
* the costly operation of searching every row multiple times, potentially a
|
* the costly operation of searching every row multiple times, potentially a
|
||||||
@@ -35,11 +36,11 @@ export class Linkifier implements ILinkifier {
|
|||||||
private _nextLinkMatcherId = 0;
|
private _nextLinkMatcherId = 0;
|
||||||
private _rowsToLinkify: { start: number | undefined, end: number | undefined };
|
private _rowsToLinkify: { start: number | undefined, end: number | undefined };
|
||||||
|
|
||||||
private _onShowLinkUnderline = new EventEmitter<ILinkifierEvent>();
|
private _onShowLinkUnderline = this.register(new EventEmitter<ILinkifierEvent>());
|
||||||
public get onShowLinkUnderline(): IEvent<ILinkifierEvent> { return this._onShowLinkUnderline.event; }
|
public get onShowLinkUnderline(): IEvent<ILinkifierEvent> { return this._onShowLinkUnderline.event; }
|
||||||
private _onHideLinkUnderline = new EventEmitter<ILinkifierEvent>();
|
private _onHideLinkUnderline = this.register(new EventEmitter<ILinkifierEvent>());
|
||||||
public get onHideLinkUnderline(): IEvent<ILinkifierEvent> { return this._onHideLinkUnderline.event; }
|
public get onHideLinkUnderline(): IEvent<ILinkifierEvent> { return this._onHideLinkUnderline.event; }
|
||||||
private _onLinkTooltip = new EventEmitter<ILinkifierEvent>();
|
private _onLinkTooltip = this.register(new EventEmitter<ILinkifierEvent>());
|
||||||
public get onLinkTooltip(): IEvent<ILinkifierEvent> { return this._onLinkTooltip.event; }
|
public get onLinkTooltip(): IEvent<ILinkifierEvent> { return this._onLinkTooltip.event; }
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -47,18 +48,13 @@ export class Linkifier implements ILinkifier {
|
|||||||
@ILogService private readonly _logService: ILogService,
|
@ILogService private readonly _logService: ILogService,
|
||||||
@IUnicodeService private readonly _unicodeService: IUnicodeService
|
@IUnicodeService private readonly _unicodeService: IUnicodeService
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
this._rowsToLinkify = {
|
this._rowsToLinkify = {
|
||||||
start: undefined,
|
start: undefined,
|
||||||
end: undefined
|
end: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(): void {
|
|
||||||
this._onShowLinkUnderline.dispose();
|
|
||||||
this._onHideLinkUnderline.dispose();
|
|
||||||
this._onLinkTooltip.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches the linkifier to the DOM, enabling linkification.
|
* Attaches the linkifier to the DOM, enabling linkification.
|
||||||
* @param mouseZoneManager The mouse zone manager to register link zones with.
|
* @param mouseZoneManager The mouse zone manager to register link zones with.
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
|
|
||||||
this._setup();
|
this._setup();
|
||||||
|
|
||||||
this.linkifier = this._instantiationService.createInstance(Linkifier);
|
this.linkifier = this.register(this._instantiationService.createInstance(Linkifier));
|
||||||
this.linkifier2 = this.register(this._instantiationService.createInstance(Linkifier2));
|
this.linkifier2 = this.register(this._instantiationService.createInstance(Linkifier2));
|
||||||
this._decorationService = this._instantiationService.createInstance(DecorationService);
|
this._decorationService = this._instantiationService.createInstance(DecorationService);
|
||||||
this._instantiationService.setService(IDecorationService, this._decorationService);
|
this._instantiationService.setService(IDecorationService, this._decorationService);
|
||||||
@@ -247,12 +247,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
this._renderService?.dispose();
|
this._renderService?.dispose();
|
||||||
this._customKeyEventHandler = undefined;
|
this._customKeyEventHandler = undefined;
|
||||||
this._overviewRulerRenderer?.dispose();
|
|
||||||
this._overviewRulerRenderer = undefined;
|
|
||||||
this.write = () => { };
|
this.write = () => { };
|
||||||
this.element?.parentNode?.removeChild(this.element);
|
this.element?.parentNode?.removeChild(this.element);
|
||||||
this.linkifier.dispose();
|
|
||||||
this.linkifier2.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _setup(): void {
|
protected _setup(): void {
|
||||||
@@ -612,11 +608,11 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.overviewRulerWidth) {
|
if (this.options.overviewRulerWidth) {
|
||||||
this._overviewRulerRenderer = this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement);
|
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
|
||||||
}
|
}
|
||||||
this.optionsService.onOptionChange(() => {
|
this.optionsService.onOptionChange(() => {
|
||||||
if (!this._overviewRulerRenderer && this.options.overviewRulerWidth && this._viewportElement && this.screenElement) {
|
if (!this._overviewRulerRenderer && this.options.overviewRulerWidth && this._viewportElement && this.screenElement) {
|
||||||
this._overviewRulerRenderer = this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement);
|
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Measure the character size
|
// Measure the character size
|
||||||
|
|||||||
Vendored
+2
-4
@@ -192,7 +192,7 @@ export interface ILinkifierEvent {
|
|||||||
fg: number | undefined;
|
fg: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILinkifier {
|
export interface ILinkifier extends IDisposable {
|
||||||
onShowLinkUnderline: IEvent<ILinkifierEvent>;
|
onShowLinkUnderline: IEvent<ILinkifierEvent>;
|
||||||
onHideLinkUnderline: IEvent<ILinkifierEvent>;
|
onHideLinkUnderline: IEvent<ILinkifierEvent>;
|
||||||
onLinkTooltip: IEvent<ILinkifierEvent>;
|
onLinkTooltip: IEvent<ILinkifierEvent>;
|
||||||
@@ -201,7 +201,6 @@ export interface ILinkifier {
|
|||||||
linkifyRows(start: number, end: number): void;
|
linkifyRows(start: number, end: number): void;
|
||||||
registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number;
|
registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number;
|
||||||
deregisterLinkMatcher(matcherId: number): boolean;
|
deregisterLinkMatcher(matcherId: number): boolean;
|
||||||
dispose(): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ILinkState {
|
interface ILinkState {
|
||||||
@@ -213,14 +212,13 @@ export interface ILinkWithState {
|
|||||||
state?: ILinkState;
|
state?: ILinkState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILinkifier2 {
|
export interface ILinkifier2 extends IDisposable {
|
||||||
onShowLinkUnderline: IEvent<ILinkifierEvent>;
|
onShowLinkUnderline: IEvent<ILinkifierEvent>;
|
||||||
onHideLinkUnderline: IEvent<ILinkifierEvent>;
|
onHideLinkUnderline: IEvent<ILinkifierEvent>;
|
||||||
readonly currentLink: ILinkWithState | undefined;
|
readonly currentLink: ILinkWithState | undefined;
|
||||||
|
|
||||||
attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void;
|
attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void;
|
||||||
registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
|
registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
|
||||||
dispose(): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILinkMatcherOptions {
|
export interface ILinkMatcherOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user