diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index 127e1f24..f504cbe9 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -20,6 +20,7 @@ export class MockBufferService implements IBufferService { public buffers: IBufferSet = {} as any; public onResize: Event<{ cols: number, rows: number }> = new Emitter<{ cols: number, rows: number }>().event; public onScroll: Event = new Emitter().event; + private readonly _onScroll = new Emitter(); public isUserScrolling: boolean = false; constructor( public cols: number, @@ -27,6 +28,10 @@ export class MockBufferService implements IBufferService { optionsService: IOptionsService = new MockOptionsService() ) { this.buffers = new BufferSet(optionsService, this); + // Listen to buffer activation events and automatically fire scroll events + this.buffers.onBufferActivate(e => { + this._onScroll.fire(e.activeBuffer.ydisp); + }); } public scrollPages(pageCount: number): void { throw new Error('Method not implemented.'); diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index c4698e68..d8d8d6b6 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -37,6 +37,9 @@ export class BufferService extends Disposable implements IBufferService { this.cols = Math.max(optionsService.rawOptions.cols || 0, MINIMUM_COLS); this.rows = Math.max(optionsService.rawOptions.rows || 0, MINIMUM_ROWS); this.buffers = this._register(new BufferSet(optionsService, this)); + this._register(this.buffers.onBufferActivate(e => { + this._onScroll.fire(e.activeBuffer.ydisp); + })); } public resize(cols: number, rows: number): void {