Use WrapSize for WindowSize when unavailable

This commit is contained in:
Andrew Schwartzmeyer 2016-05-17 12:10:45 -07:00
parent 7afe9aa60f
commit b67d765b3a
2 changed files with 12 additions and 2 deletions

View file

@ -1653,7 +1653,17 @@ namespace Microsoft.PowerShell
/// </summary>
public override Size WindowSize
{
get { return new Size(Console.WindowWidth, Console.WindowHeight); }
get
{
if (Console.IsOutputRedirected)
{
return WrapSize;
}
else
{
return new Size(Console.WindowWidth, Console.WindowHeight);
}
}
set { Console.SetWindowSize(value.Width, value.Height); }
}

View file

@ -1148,7 +1148,7 @@ namespace Microsoft.PowerShell
// we leave a 1-cell margin on the end because if the very last character butts up against the
// edge of the screen buffer, then the console will wrap the line.
List<string> lines = WrapText(text, RawUI.BufferSize.Width - 1);
List<string> lines = WrapText(text, RawUI.WindowSize.Width - 1);
int count = 0;
foreach (string s in lines)
{