Skip to content

Commit

Permalink
repl: add new line on ctrl+d
Browse files Browse the repository at this point in the history
Currently the repl ends on the same line which procudes a weird
output. To prevent that, just add a new line in case of ctrl+d.

PR-URL: #26240
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
BridgeAR authored and addaleax committed Mar 1, 2019
1 parent f636f15 commit 2fa8170
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,11 @@ function REPLServer(prompt,
return;
}
if (!self.editorMode || !self.terminal) {
// Before exiting, make sure to clear the line.
if (key.ctrl && key.name === 'd' &&
self.cursor === 0 && self.line.length === 0) {
self.clearLine();
}
ttyWrite(d, key);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-save-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
putIn.run([`.save ${saveFileName}`]);
replServer.close();
assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
`${cmds.join('\n')}\n`);
`${cmds.join('\n')}\n\n`);
}

// make sure that the REPL data is "correct"
Expand Down

0 comments on commit 2fa8170

Please sign in to comment.