Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

lib/readline.js: Fix backspace for multi-line(\n) #7128

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/readline.js
Expand Up @@ -228,7 +228,7 @@ Interface.prototype._refreshLine = function() {
}

// Cursor to left edge.
exports.cursorTo(this.output, 0);
exports.cursorTo(this.output, 0, 0);
// erase data
exports.clearScreenDown(this.output);

Expand Down Expand Up @@ -580,7 +580,9 @@ Interface.prototype._getDisplayPos = function(str) {
// Returns current cursor's position and line
Interface.prototype._getCursorPos = function() {
var columns = this.columns;
var strBeforeCursor = this._prompt + this.line.substring(0, this.cursor);
var linesOfPrompt = this._prompt.split('\n');
var strBeforeCursor = linesOfPrompt[linesOfPrompt.length - 1];
strBeforeCursor += this.line.substring(0, this.cursor);
var dispPos = this._getDisplayPos(stripVTControlCharacters(strBeforeCursor));
var cols = dispPos.cols;
var rows = dispPos.rows;
Expand Down