Skip to content

Commit fffdaeb

Browse files
committed
readline: fix behaviour of Interface plugged to a non-terminal output
Fixes: #36773 PR-URL: #36774 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 9d35b92 commit fffdaeb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/readline.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ function Interface(input, output, completer, terminal) {
282282
input.on('keypress', onkeypress);
283283
input.on('end', ontermend);
284284

285-
// Current line
286-
this.line = '';
287-
288285
this._setRawMode(true);
289286
this.terminal = true;
290287

@@ -300,6 +297,9 @@ function Interface(input, output, completer, terminal) {
300297
self.once('close', onSelfCloseWithTerminal);
301298
}
302299

300+
// Current line
301+
this.line = '';
302+
303303
input.resume();
304304
}
305305

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
const repl = require('repl');
5+
const r = repl.start({ terminal: false });
6+
r.setupHistory('/nonexistent/file', common.mustSucceed());
7+
process.stdin.unref?.();

0 commit comments

Comments
 (0)