@@ -549,6 +549,7 @@ private string InputLoop()
549549 var visualSelectionCommandCount = _visualSelectionCommandCount ;
550550 var moveToLineCommandCount = _moveToLineCommandCount ;
551551 var moveToEndOfLineCommandCount = _moveToEndOfLineCommandCount ;
552+ var editsCount = _edits . Count ;
552553
553554 // We attempt to handle window resizing only once per a keybinding processing, because we assume the
554555 // window resizing cannot and shouldn't happen within the processing of a given keybinding.
@@ -614,12 +615,25 @@ private string InputLoop()
614615 {
615616 if ( _anyHistoryCommandCount > 0 )
616617 {
617- ClearSavedCurrentLine ( ) ;
618- _hashedHistory = null ;
619- _currentHistoryIndex = _history . Count ;
618+ // _savedCurrentLine is consumed only if current line has the same content
619+ if ( _savedCurrentLine . CommandLine == _buffer . ToString ( ) )
620+ {
621+ ClearSavedCurrentLine ( ) ;
622+ _hashedHistory = null ;
623+ _currentHistoryIndex = _history . Count ;
624+ }
620625 }
621626 _anyHistoryCommandCount = 0 ;
622627 }
628+ // if (editsCount < _edits.Count)
629+ // {
630+ // // if previous line with _currentHistoryIndex range 0 to _history.Count - 1(meaning it was recalled) has been edited
631+ // // it become effectively a new command, so we should reset _currentHistoryIndex
632+ // if (_currentHistoryIndex != _history.Count)
633+ // {
634+ // _currentHistoryIndex = _history.Count;
635+ // }
636+ // }
623637 if ( visualSelectionCommandCount == _visualSelectionCommandCount && _visualSelectionCommandCount > 0 )
624638 {
625639 _visualSelectionCommandCount = 0 ;
0 commit comments