Skip to content

Commit 3025a52

Browse files
committed
Fix HistorySearch* when line is empty
The commit 49a4c4c broke arrow keys working when the line was empty and you wanted to go back more than one command.
1 parent 8311386 commit 3025a52

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

PSReadLine/History.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,6 @@ public static void NextHistory(ConsoleKeyInfo? key = null, object arg = null)
387387

388388
private void HistorySearch(int direction)
389389
{
390-
if (_current == 0)
391-
{
392-
// If we aren't actually searching, use HistoryRecall
393-
// because it ignores command lines from other running sessions.
394-
HistoryRecall(direction);
395-
return;
396-
}
397-
398390
if (_searchHistoryCommandCount == 0)
399391
{
400392
if (LineIsMultiLine())
@@ -424,6 +416,11 @@ private void HistorySearch(int direction)
424416
break;
425417
}
426418

419+
if (_history[newHistoryIndex]._fromDifferentLiveSession && _searchHistoryPrefix.Length == 0)
420+
{
421+
continue;
422+
}
423+
427424
var line = newHistoryIndex == _history.Count ? _savedCurrentLine._line : _history[newHistoryIndex]._line;
428425
if (line.StartsWith(_searchHistoryPrefix, Options.HistoryStringComparison))
429426
{

0 commit comments

Comments
 (0)