Skip to content
Open
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
12 changes: 7 additions & 5 deletions lib/internal/readline/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ function InterfaceConstructor(input, output, completer, terminal) {
let crlfDelay;
let prompt = '> ';
let signal;
let historySize;
let history;
let removeHistoryDuplicates;

if (input?.input) {
// An options object was given
Expand All @@ -181,9 +184,9 @@ function InterfaceConstructor(input, output, completer, terminal) {
signal = input.signal;

// It is possible to configure the history through the input object
const historySize = input.historySize;
const history = input.history;
const removeHistoryDuplicates = input.removeHistoryDuplicates;
historySize = input.historySize;
history = input.history;
removeHistoryDuplicates = input.removeHistoryDuplicates;

if (input.tabSize !== undefined) {
validateUint32(input.tabSize, 'tabSize', true);
Expand Down Expand Up @@ -215,8 +218,6 @@ function InterfaceConstructor(input, output, completer, terminal) {
input.removeHistoryDuplicates = removeHistoryDuplicates;
}

this.setupHistoryManager(input);

if (completer !== undefined && typeof completer !== 'function') {
throw new ERR_INVALID_ARG_VALUE('completer', completer);
}
Expand All @@ -234,6 +235,7 @@ function InterfaceConstructor(input, output, completer, terminal) {
this[kSubstringSearch] = null;
this.output = output;
this.input = input;
this.setupHistoryManager(input);
this[kUndoStack] = [];
this[kRedoStack] = [];
this[kPreviousCursorCols] = -1;
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-readline-history-init-order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const readline = require('readline');
const assert = require('assert');

assert.doesNotThrow(() => {
const input = new Proxy({}, {
get(_target, prop) {
if (prop === 'pause') return () => {};
if (prop === 'resume') return () => {};
return () => {};
},
});

readline.createInterface(input);
});