Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,19 @@ function _ttyWriteDumb(s, key) {
if (this._sawReturnAt && key.name !== 'enter')
this._sawReturnAt = 0;

if (key.ctrl && key.name === 'c') {
if (this.listenerCount('SIGINT') > 0) {
this.emit('SIGINT');
} else {
// This readline instance is finished
if (key.ctrl) {
if (key.name === 'c') {
if (this.listenerCount('SIGINT') > 0) {
this.emit('SIGINT');
} else {
// This readline instance is finished
this.close();
}

return;
} else if (key.name === 'd') {
this.close();
return;
}
}

Expand Down
18 changes: 17 additions & 1 deletion test/pseudo-tty/repl-dumb-tty.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';
require('../common');
const common = require('../common');

process.env.TERM = 'dumb';

const repl = require('repl');
const ArrayStream = require('../common/arraystream');

repl.start('> ');
process.stdin.push('console.log("foo")\n');
Expand All @@ -13,3 +14,18 @@ process.stdin.push('console.dir({ a: 1 })\n');
process.stdin.push('{ a: 1 }\n');
process.stdin.push('\n');
process.stdin.push('.exit\n');

// Verify Control+D support.
{
const stream = new ArrayStream();
const replServer = repl.start({
prompt: '> ',
terminal: true,
input: stream,
output: stream,
useColors: false
});

replServer.on('close', common.mustCall());
replServer.write(null, { ctrl: true, name: 'd' });
}