Skip to content

Commit 2fa8170

Browse files
BridgeARaddaleax
authored andcommitted
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: #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]>
1 parent f636f15 commit 2fa8170

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/repl.js

+5
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,11 @@ function REPLServer(prompt,
701701
return;
702702
}
703703
if (!self.editorMode || !self.terminal) {
704+
// Before exiting, make sure to clear the line.
705+
if (key.ctrl && key.name === 'd' &&
706+
self.cursor === 0 && self.line.length === 0) {
707+
self.clearLine();
708+
}
704709
ttyWrite(d, key);
705710
return;
706711
}

test/parallel/test-repl-save-load.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
7070
putIn.run([`.save ${saveFileName}`]);
7171
replServer.close();
7272
assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
73-
`${cmds.join('\n')}\n`);
73+
`${cmds.join('\n')}\n\n`);
7474
}
7575

7676
// make sure that the REPL data is "correct"

0 commit comments

Comments
 (0)