From ab518ae50e480b5ffe01bdaaabd8c652200d1d55 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Fri, 23 Mar 2012 11:24:06 -0700 Subject: [PATCH] readline: fix for terminals that insert newlines automatically Fixes #2985. --- lib/readline.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index e0d801e87f..3a3d244f22 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -269,7 +269,12 @@ Interface.prototype._insertString = function(c) { } else { this.line += c; this.cursor += c.length; - this.output.write(c); + + if (this._getCursorPos().cols === 0) { + this._refreshLine(); + } else { + this.output.write(c); + } // a hack to get the line refreshed if it's needed this._moveCursor(0); @@ -508,7 +513,7 @@ Interface.prototype._moveCursor = function(dx) { var newPos = this._getCursorPos(); // check if cursors are in the same line - if (oldPos.rows == newPos.rows && newPos.cols != 0) { + if (oldPos.rows === newPos.rows) { this.output.moveCursor(this.cursor - oldcursor, 0); this.prevRows = newPos.rows; } else {