mirror of https://github.com/nodejs/node.git
repl: better SIGINT handling behavior
Before: ☮ ~ (master) ⚡ node > asdf (^C again to quit) > sdcasd☮ ~ (master) ⚡ Now: ☮ ~/node (repl) ⚡ ./node > asfs > sda > (^C again to quit) > scdsdc > sdcsdc > (^C again to quit) > sdc > (^C again to quit) > ☮ ~/node (repl) ⚡ ^ note that each new line above is a ctrl+c sequencepull/24503/head
parent
6b5a34cdf3
commit
f214758dd1
20
lib/repl.js
20
lib/repl.js
|
@ -140,20 +140,22 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
|
|||
rli.on('SIGINT', function() {
|
||||
rli.output.write('\n');
|
||||
|
||||
if (sawSIGINT) {
|
||||
rli.pause();
|
||||
self.emit('exit');
|
||||
if (!(self.bufferedCommand && self.bufferedCommand.length > 0) &&
|
||||
rli.line.length === 0) {
|
||||
if (sawSIGINT) {
|
||||
rli.pause();
|
||||
self.emit('exit');
|
||||
sawSIGINT = false;
|
||||
return;
|
||||
}
|
||||
rli.output.write('(^C again to quit)\n');
|
||||
sawSIGINT = true;
|
||||
} else {
|
||||
sawSIGINT = false;
|
||||
return;
|
||||
}
|
||||
|
||||
rli.line = '';
|
||||
|
||||
if (!(self.bufferedCommand && self.bufferedCommand.length > 0)) {
|
||||
rli.output.write('(^C again to quit)\n');
|
||||
sawSIGINT = true;
|
||||
}
|
||||
|
||||
self.bufferedCommand = '';
|
||||
self.displayPrompt();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue