@@ -144,7 +144,6 @@ const kYank = Symbol('_yank');
144144const kYanking = Symbol ( '_yanking' ) ;
145145const kYankPop = Symbol ( '_yankPop' ) ;
146146const kNormalizeHistoryLineEndings = Symbol ( '_normalizeHistoryLineEndings' ) ;
147- const kDenormalizeHistoryLineEndings = Symbol ( '_denormalizeHistoryLineEndings' ) ;
148147
149148function InterfaceConstructor ( input , output , completer , terminal ) {
150149 this [ kSawReturnAt ] = 0 ;
@@ -461,13 +460,8 @@ class Interface extends InterfaceConstructor {
461460 }
462461
463462 // Convert newlines to a consistent format for history storage
464- [ kNormalizeHistoryLineEndings ] ( line ) {
465- return StringPrototypeReplaceAll ( line , '\n' , '\r' ) ;
466- }
467-
468- // Convert newlines back to the format expected by the UI
469- [ kDenormalizeHistoryLineEndings ] ( line ) {
470- return StringPrototypeReplaceAll ( line , '\r' , '\n' ) ;
463+ [ kNormalizeHistoryLineEndings ] ( line , from , to ) {
464+ return StringPrototypeReplaceAll ( line , from , to ) ;
471465 }
472466
473467 [ kAddHistory ] ( ) {
@@ -478,7 +472,7 @@ class Interface extends InterfaceConstructor {
478472
479473 // If the trimmed line is empty then return the line
480474 if ( StringPrototypeTrim ( this . line ) . length === 0 ) return this . line ;
481- const normalizedLine = this [ kNormalizeHistoryLineEndings ] ( this . line ) ;
475+ const normalizedLine = this [ kNormalizeHistoryLineEndings ] ( this . line , '\n' , '\r' ) ;
482476
483477 if ( this . history . length === 0 || this . history [ 0 ] !== normalizedLine ) {
484478 if ( this [ kLastCommandErrored ] && this . historyIndex === 0 ) {
@@ -1021,7 +1015,7 @@ class Interface extends InterfaceConstructor {
10211015 if ( index === - 1 ) {
10221016 this [ kSetLine ] ( search ) ;
10231017 } else {
1024- this [ kSetLine ] ( this [ kDenormalizeHistoryLineEndings ] ( this . history [ index ] ) ) ;
1018+ this [ kSetLine ] ( this [ kNormalizeHistoryLineEndings ] ( this . history [ index ] , '\r' , '\n' ) ) ;
10251019 }
10261020 this . historyIndex = index ;
10271021 this . cursor = this . line . length ; // Set cursor to end of line.
@@ -1065,7 +1059,7 @@ class Interface extends InterfaceConstructor {
10651059 if ( index === this . history . length ) {
10661060 this [ kSetLine ] ( search ) ;
10671061 } else {
1068- this [ kSetLine ] ( this [ kDenormalizeHistoryLineEndings ] ( this . history [ index ] ) ) ;
1062+ this [ kSetLine ] ( this [ kNormalizeHistoryLineEndings ] ( this . history [ index ] , '\r' , '\n' ) ) ;
10691063 }
10701064 this . historyIndex = index ;
10711065 this . cursor = this . line . length ; // Set cursor to end of line.
@@ -1511,5 +1505,4 @@ module.exports = {
15111505 kMultilinePrompt,
15121506 kLastCommandErrored,
15131507 kNormalizeHistoryLineEndings,
1514- kDenormalizeHistoryLineEndings,
15151508} ;
0 commit comments