From 5133f25fb7d47ba98080b3e03fd86fda771f71e0 Mon Sep 17 00:00:00 2001 From: Andres Mejia Date: Tue, 16 Jan 2018 18:27:00 -0500 Subject: [PATCH] Fix issue with resetting terminal. Ensure new BufferSet is used and clear selection manager on reset. --- src/SelectionManager.ts | 4 ++++ src/Terminal.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index e625ab73..33585f98 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -121,6 +121,10 @@ export class SelectionManager extends EventEmitter implements ISelectionManager this._mouseUpListener = event => this._onMouseUp(event); this._trimListener = (amount: number) => this._onTrim(amount); + this.initBuffersListeners(); + } + + public initBuffersListeners(): void { this._terminal.buffer.lines.on('trim', this._trimListener); this._terminal.buffers.on('activate', e => this._onBufferActivate(e)); } diff --git a/src/Terminal.ts b/src/Terminal.ts index 02c74a3d..8b38fdbd 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -292,6 +292,10 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT // Create the terminal's buffers and set the current buffer this.buffers = new BufferSet(this); + if (this.selectionManager) { + this.selectionManager.clearSelection(); + this.selectionManager.initBuffersListeners(); + } } /** @@ -2076,11 +2080,9 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.options.cols = this.cols; const customKeyEventHandler = this.customKeyEventHandler; const inputHandler = this.inputHandler; - const buffers = this.buffers; this.setup(); this.customKeyEventHandler = customKeyEventHandler; this.inputHandler = inputHandler; - this.buffers = buffers; this.refresh(0, this.rows - 1); this.viewport.syncScrollArea(); }