Skip to content

Commit

Permalink
readline: fix behaviour of Interface plugged to a non-terminal output
Browse files Browse the repository at this point in the history
Fixes: #36773

PR-URL: #36774
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
aduh95 authored and targos committed May 1, 2021
1 parent 1521a59 commit 70cbe4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/readline.js
Expand Up @@ -252,9 +252,6 @@ function Interface(input, output, completer, terminal) {
input.on('keypress', onkeypress);
input.on('end', ontermend);

// Current line
this.line = '';

this._setRawMode(true);
this.terminal = true;

Expand All @@ -270,6 +267,9 @@ function Interface(input, output, completer, terminal) {
self.once('close', onSelfCloseWithTerminal);
}

// Current line
this.line = '';

input.resume();
}

Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-repl-no-terminal.js
@@ -0,0 +1,7 @@
'use strict';
const common = require('../common');

const repl = require('repl');
const r = repl.start({ terminal: false });
r.setupHistory('/nonexistent/file', common.mustSucceed());
process.stdin.unref?.();

0 comments on commit 70cbe4a

Please sign in to comment.