@@ -235,7 +235,24 @@ function InterfaceConstructor(input, output, completer, terminal) {
235235 this [ kSubstringSearch ] = null ;
236236 this . output = output ;
237237 this . input = input ;
238- this . setupHistoryManager ( inputOptions || input ) ;
238+
239+ // If inputOptions was provided (constructor with options object),
240+ // copy the stream's size/history properties back to it for setupHistoryManager
241+ let historyOptions = inputOptions || input ;
242+ if ( inputOptions !== undefined && input !== undefined &&
243+ inputOptions !== input ) {
244+ if ( input . size !== undefined && historyOptions . size === undefined ) {
245+ historyOptions . size = input . size ;
246+ }
247+ if ( input . history !== undefined && historyOptions . history === undefined ) {
248+ historyOptions . history = input . history ;
249+ }
250+ if ( input . removeHistoryDuplicates !== undefined &&
251+ historyOptions . removeHistoryDuplicates === undefined ) {
252+ historyOptions . removeHistoryDuplicates = input . removeHistoryDuplicates ;
253+ }
254+ }
255+ this . setupHistoryManager ( historyOptions ) ;
239256 this [ kUndoStack ] = [ ] ;
240257 this [ kRedoStack ] = [ ] ;
241258 this [ kPreviousCursorCols ] = - 1 ;
@@ -387,15 +404,15 @@ class Interface extends InterfaceConstructor {
387404 this . historyManager = new ReplHistory ( this , options ) ;
388405
389406 // Only initialize REPL history when called from REPL.setupHistory(),
390- // not from the readline constructor.
407+ // not from the readline constructor.
391408 // Constructor passes: stream OR { input: stream, output: stream, ... }
392409 // setupHistory passes: { filePath: ..., size: ..., onHistoryFileLoaded: ... }
393410 // Detect constructor calls by checking for stream.on() or options.input
394411 if ( options && typeof options === 'object' ) {
395412 const isStream = typeof options . on === 'function' ;
396413 const hasInputProperty = options . input !== undefined ;
397414 const isFromConstructor = isStream || hasInputProperty ;
398-
415+
399416 if ( ! isFromConstructor && typeof options . onHistoryFileLoaded === 'function' ) {
400417 this . historyManager . initialize ( options . onHistoryFileLoaded ) ;
401418 }
0 commit comments