readline: fix for terminals that insert newlines automatically
Fixes #2985.
This commit is contained in:
Родитель
e7792e5d46
Коммит
ab518ae50e
|
@ -269,7 +269,12 @@ Interface.prototype._insertString = function(c) {
|
||||||
} else {
|
} else {
|
||||||
this.line += c;
|
this.line += c;
|
||||||
this.cursor += c.length;
|
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
|
// a hack to get the line refreshed if it's needed
|
||||||
this._moveCursor(0);
|
this._moveCursor(0);
|
||||||
|
@ -508,7 +513,7 @@ Interface.prototype._moveCursor = function(dx) {
|
||||||
var newPos = this._getCursorPos();
|
var newPos = this._getCursorPos();
|
||||||
|
|
||||||
// check if cursors are in the same line
|
// 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.output.moveCursor(this.cursor - oldcursor, 0);
|
||||||
this.prevRows = newPos.rows;
|
this.prevRows = newPos.rows;
|
||||||
} else {
|
} else {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче