diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 50a43bf1..936aa0c8 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -71,10 +71,19 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; } protected _onScroll = new EventEmitter(); /** - * An emitter for legacy on scroll events that just included the position, and not the source. - * Used to maintain API consistency for the onScroll method. + * Internally we track the source of the scroll but this is meaningless outside the library so + * it's filtered out. */ - protected _legacyOnScroll?: EventEmitter; + protected _onScrollApi?: EventEmitter; + public get onScroll(): IEvent { + if (!this._onScrollApi) { + this._onScrollApi = new EventEmitter(); + this.register(this._onScroll.event(ev => { + this._onScrollApi?.fire(ev.position); + })); + } + return this._onScrollApi.event; + } public get cols(): number { return this._bufferService.cols; } public get rows(): number { return this._bufferService.rows; } @@ -287,16 +296,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { } } - public get onScroll(): IEvent { - if (!this._legacyOnScroll) { - this._legacyOnScroll = new EventEmitter(); - this.register(this._onScroll.event(ev => { - this._legacyOnScroll?.fire(ev.position); - })); - } - return this._legacyOnScroll.event; - } - /** Add handler for ESC escape sequence. See xterm.d.ts for details. */ public registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable { return this._inputHandler.registerEscHandler(id, callback);