diff --git a/PSReadLine/Prediction.Views.cs b/PSReadLine/Prediction.Views.cs index 91ef8437..8def76e3 100644 --- a/PSReadLine/Prediction.Views.cs +++ b/PSReadLine/Prediction.Views.cs @@ -389,7 +389,7 @@ internal override void GetSuggestion(string userInput) _listItems = GetHistorySuggestions(userInput, HistoryMaxCount); if (_listItems?.Count > 0) { - _sources = new List() { new SourceInfo(SuggestionEntry.HistorySource, _listItems.Count - 1, -1) }; + _sources = new List() { new SourceInfo(SuggestionEntry.HistorySource, _listItems.Count - 1, prevSourceEndIndex: -1) }; } } } @@ -546,6 +546,7 @@ private void AggregateSuggestions() int count = _cacheList2[index] - num; if (count > 0) { + // If we had at least one source, we take the end index of the last source in the list. int prevEndIndex = _sources.Count > 0 ? _sources[_sources.Count - 1].EndIndex : -1; int endIndex = _listItems.Count - 1; _sources.Add(new SourceInfo(_listItems[endIndex].Source, endIndex, prevEndIndex));