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 <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
BridgeAR authored and danbev committed Feb 28, 2019
1 parent ff64c67 commit 1976909
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 @@ -700,6 +700,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 1976909

Please sign in to comment.