Skip to content

Commit a9263c2

Browse files
author
Branden Conley
committed
ParserSettings and HelpText assume that Console.WindowWidth throws for non-Windows environments, but this is not true in more recent versions of Mono (returns 0 instead). This change will cause it to default to DefaultMaximumLength in the event that Console.WindowWidth returns 0.
1 parent c363001 commit a9263c2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/CommandLine/ParserSettings.cs

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public ParserSettings()
3535
try
3636
{
3737
maximumDisplayWidth = Console.WindowWidth;
38+
if (maximumDisplayWidth < 1)
39+
{
40+
maximumDisplayWidth = DefaultMaximumLength;
41+
}
3842
}
3943
catch (IOException)
4044
{

src/CommandLine/Text/HelpText.cs

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public HelpText(SentenceBuilder sentenceBuilder, string heading, string copyrigh
105105
try
106106
{
107107
maximumDisplayWidth = Console.WindowWidth;
108+
if (maximumDisplayWidth < 1)
109+
{
110+
maximumDisplayWidth = DefaultMaximumLength;
111+
}
108112
}
109113
catch (IOException)
110114
{

0 commit comments

Comments
 (0)