mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Guard BufferSize for improper terminals
This commit is contained in:
1 parent
86e8673826
commit
fbc794b933
1 file changed
+16
-1
@@ -1551,7 +1551,22 @@ namespace Microsoft.PowerShell
|
||||
/// </summary>
|
||||
public override Size BufferSize
|
||||
{
|
||||
get { return new Size(Console.BufferWidth, Console.BufferHeight); }
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Size(Console.BufferWidth, Console.BufferHeight);
|
||||
}
|
||||
catch (System.IO.IOException)
|
||||
{
|
||||
// When running without a proper terminal (like on AppVeyor)
|
||||
// the above will throw because there is no available buffer
|
||||
// information, so we make a good guess here (since this
|
||||
// size is mostly used for formatting, this lets wrapping
|
||||
// work well).
|
||||
return new Size(80, 80);
|
||||
}
|
||||
}
|
||||
set { Console.SetBufferSize(value.Width, value.Height); }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user