Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions PSReadLine/Cmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/ListPredictionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
27 changes: 27 additions & 0 deletions test/ListScrollableViewTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Management.Automation.Runspaces;
using Microsoft.PowerShell;
using Xunit;

Expand Down Expand Up @@ -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<PSConsoleReadLineOptions>(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);
}
}
}