Skip to content
Open
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
20 changes: 17 additions & 3 deletions PSReadLine/ReadLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ private string InputLoop()
var visualSelectionCommandCount = _visualSelectionCommandCount;
var moveToLineCommandCount = _moveToLineCommandCount;
var moveToEndOfLineCommandCount = _moveToEndOfLineCommandCount;
var editsCount = _edits.Count;

// We attempt to handle window resizing only once per a keybinding processing, because we assume the
// window resizing cannot and shouldn't happen within the processing of a given keybinding.
Expand Down Expand Up @@ -614,12 +615,25 @@ private string InputLoop()
{
if (_anyHistoryCommandCount > 0)
{
ClearSavedCurrentLine();
_hashedHistory = null;
_currentHistoryIndex = _history.Count;
// _savedCurrentLine is consumed only if current line has the same content
if (_savedCurrentLine.CommandLine == _buffer.ToString())
{
ClearSavedCurrentLine();
_hashedHistory = null;
_currentHistoryIndex = _history.Count;
}
}
_anyHistoryCommandCount = 0;
}
// if (editsCount < _edits.Count)
// {
// // if previous line with _currentHistoryIndex range 0 to _history.Count - 1(meaning it was recalled) has been edited
// // it become effectively a new command, so we should reset _currentHistoryIndex
// if (_currentHistoryIndex != _history.Count)
// {
// _currentHistoryIndex = _history.Count;
// }
// }
if (visualSelectionCommandCount == _visualSelectionCommandCount && _visualSelectionCommandCount > 0)
{
_visualSelectionCommandCount = 0;
Expand Down