diff --git a/PSReadLine/Cmdlets.cs b/PSReadLine/Cmdlets.cs index 596b1548..c0287a14 100644 --- a/PSReadLine/Cmdlets.cs +++ b/PSReadLine/Cmdlets.cs @@ -634,9 +634,7 @@ public class GetPSReadLineOption : PSCmdlet [ExcludeFromCodeCoverage] protected override void EndProcessing() { - var options = PSConsoleReadLine.GetOptions(); - WriteObject(options); - PSConsoleReadLine.WarnWhenWindowSizeTooSmallForView(options.PredictionViewStyle, this); + WriteObject(PSConsoleReadLine.GetOptions()); } } diff --git a/test/ListPredictionTest.cs b/test/ListPredictionTest.cs index a0a42696..1dd6eaed 100644 --- a/test/ListPredictionTest.cs +++ b/test/ListPredictionTest.cs @@ -9,7 +9,7 @@ public partial class ReadLine // The source of truth is defined in 'Microsoft.PowerShell.PSConsoleReadLine+PredictionListView'. // Make sure the values are in sync. private const int MinWindowWidth = 50; - private const int MinWindowHeight = 15; + private const int MinWindowHeight = 5; private const int ListMaxWidth = 100; private const int SourceMaxWidth = 15; diff --git a/test/ListScrollableViewTest.cs b/test/ListScrollableViewTest.cs index 3452c462..169b3837 100644 --- a/test/ListScrollableViewTest.cs +++ b/test/ListScrollableViewTest.cs @@ -1,4 +1,5 @@ using System; +using System.Management.Automation.Runspaces; using Microsoft.PowerShell; using Xunit; @@ -910,5 +911,31 @@ public void ListView_TermSize_Warning() NextLine)) )); } + + [SkippableFact] + public void ListView_TermSize_WarningOnlyFromSetOption() + { + Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode."); + + // The console is under the list view minimum. 'F2' switches the view without + // 'Set-PSReadLineOption', so the two cmdlets can be measured separately. + TestSetup(new TestConsole(keyboardLayout: _, width: 40, height: 4), KeyMode.Cmd); + using var disp = SetPrediction(PredictionSource.History, PredictionViewStyle.InlineView); + Test("", Keys(_.F2, _.Enter)); + + var iss = InitialSessionState.CreateDefault(); + iss.Commands.Add(new SessionStateCmdletEntry("Get-PSReadLineOption", typeof(GetPSReadLineOption), helpFileName: null)); + iss.Commands.Add(new SessionStateCmdletEntry("Set-PSReadLineOption", typeof(SetPSReadLineOption), helpFileName: null)); + using var ps = System.Management.Automation.PowerShell.Create(iss); + + var result = ps.AddCommand("Get-PSReadLineOption").Invoke(); + var options = Assert.IsType(Assert.Single(result).BaseObject); + Assert.Equal(PredictionViewStyle.ListView, options.PredictionViewStyle); + Assert.Empty(ps.Streams.Warning); + + ps.Commands.Clear(); + ps.AddCommand("Set-PSReadLineOption").AddParameter("PredictionViewStyle", PredictionViewStyle.ListView).Invoke(); + Assert.Single(ps.Streams.Warning); + } } }