From 2bc8adee8c3cce6c96cd9b74e235964735837c14 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 28 Nov 2016 10:41:03 -0800 Subject: [PATCH] Scroll to bottom whenever handler is called This catches all current and future cases for correctly scrolling to the bottom on input by handling it in the handler immediately before emitting the data event. Fixes #378 --- src/xterm.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index 752d832..e6482c4 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -2458,11 +2458,6 @@ Terminal.prototype.keyDown = function(ev) { return true; } - // Scroll down to prompt, whenever the user presses a key. - if (this.ybase !== this.ydisp) { - this.scrollToBottom(); - } - this.emit('keydown', ev); this.emit('key', result.key, ev); this.showCursor(); @@ -3153,6 +3148,10 @@ Terminal.prototype.is = function(term) { * @param {string} data The data to populate in the event. */ Terminal.prototype.handler = function(data) { + // Input is being sent to the terminal, the terminal should focus the prompt. + if (this.ybase !== this.ydisp) { + this.scrollToBottom(); + } this.emit('data', data); };