Move over to vs disposables

This commit is contained in:
Daniel Imms
2024-07-14 16:19:20 -07:00
parent aee936264b
commit 144bdb5dd0
43 changed files with 349 additions and 470 deletions
+11 -11
View File
@@ -28,15 +28,15 @@ import { IMarker, ITerminalOptions } from 'common/Types';
import { Emitter, Event } from 'vs/base/common/event';
export class Terminal extends CoreTerminal {
private readonly _onBell = this.register(new Emitter<void>());
private readonly _onBell = this._register(new Emitter<void>());
public readonly onBell = this._onBell.event;
private readonly _onCursorMove = this.register(new Emitter<void>());
private readonly _onCursorMove = this._register(new Emitter<void>());
public readonly onCursorMove = this._onCursorMove.event;
private readonly _onTitleChange = this.register(new Emitter<string>());
private readonly _onTitleChange = this._register(new Emitter<string>());
public readonly onTitleChange = this._onTitleChange.event;
private readonly _onA11yCharEmitter = this.register(new Emitter<string>());
private readonly _onA11yCharEmitter = this._register(new Emitter<string>());
public readonly onA11yChar = this._onA11yCharEmitter.event;
private readonly _onA11yTabEmitter = this.register(new Emitter<number>());
private readonly _onA11yTabEmitter = this._register(new Emitter<number>());
public readonly onA11yTab = this._onA11yTabEmitter.event;
constructor(
@@ -47,12 +47,12 @@ export class Terminal extends CoreTerminal {
this._setup();
// Setup InputHandler listeners
this.register(this._inputHandler.onRequestBell(() => this.bell()));
this.register(this._inputHandler.onRequestReset(() => this.reset()));
this.register(Event.forward(this._inputHandler.onCursorMove, this._onCursorMove));
this.register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
this.register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this.register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
this._register(this._inputHandler.onRequestBell(() => this.bell()));
this._register(this._inputHandler.onRequestReset(() => this.reset()));
this._register(Event.forward(this._inputHandler.onCursorMove, this._onCursorMove));
this._register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
this._register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this._register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
}
/**
+4 -4
View File
@@ -10,7 +10,7 @@ import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITer
import { Terminal as TerminalCore } from 'headless/Terminal';
import { AddonManager } from 'common/public/AddonManager';
import { ITerminalOptions } from 'common/Types';
import { Disposable } from 'common/Lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
import type { Event } from 'vs/base/common/event';
/**
* The set of options that only have an effect when set in the Terminal constructor.
@@ -27,8 +27,8 @@ export class Terminal extends Disposable implements ITerminalApi {
constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions) {
super();
this._core = this.register(new TerminalCore(options));
this._addonManager = this.register(new AddonManager());
this._core = this._register(new TerminalCore(options));
this._addonManager = this._register(new AddonManager());
this._publicOptions = { ... this._core.options };
const getter = (propName: string): any => {
@@ -98,7 +98,7 @@ export class Terminal extends Disposable implements ITerminalApi {
public get buffer(): IBufferNamespaceApi {
this._checkProposedApi();
if (!this._buffer) {
this._buffer = this.register(new BufferNamespaceApi(this._core));
this._buffer = this._register(new BufferNamespaceApi(this._core));
}
return this._buffer;
}