From 4f977b1ad990cdc9af8d26db1dbf0cf8715b3bad Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 6 Jul 2022 13:53:06 -0700 Subject: [PATCH] No list view prediction when the first line was scrolled up off the buffer --- PSReadLine/Prediction.Views.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PSReadLine/Prediction.Views.cs b/PSReadLine/Prediction.Views.cs index e61d396cd..ce1eec3e8 100644 --- a/PSReadLine/Prediction.Views.cs +++ b/PSReadLine/Prediction.Views.cs @@ -275,6 +275,13 @@ internal PredictionListView(PSConsoleReadLine singleton) internal override void GetSuggestion(string userInput) { + if (_singleton._initialY < 0) + { + // Do not trigger list view prediction when the first line has already been scrolled up off the buffer. + // See https://github.com/PowerShell/PSReadLine/issues/3347 for an example where this may happen. + return; + } + bool inputUnchanged = string.Equals(_inputText, userInput, _singleton._options.HistoryStringComparison); if (!inputUnchanged && _selectedIndex > -1) {