repl: add new line on ctrl+d

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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Ruben Bridgewater authored and Anna Henningsen committed 2019-03-01 10:27:23 +01:00
1 parent f636f15315
commit 2fa8170e51
2 files changed
+6 -1

No files matched your search

+5
View File
@@ -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;
}
+1 -1
View File
@@ -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"