From a9263c2239e6d9bbcb05fc814de3869abf849a45 Mon Sep 17 00:00:00 2001 From: Branden Conley Date: Mon, 23 Apr 2018 14:24:23 -0600 Subject: [PATCH] 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. --- src/CommandLine/ParserSettings.cs | 4 ++++ src/CommandLine/Text/HelpText.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/CommandLine/ParserSettings.cs b/src/CommandLine/ParserSettings.cs index 93962566..e0a1423a 100644 --- a/src/CommandLine/ParserSettings.cs +++ b/src/CommandLine/ParserSettings.cs @@ -35,6 +35,10 @@ public ParserSettings() try { maximumDisplayWidth = Console.WindowWidth; + if (maximumDisplayWidth < 1) + { + maximumDisplayWidth = DefaultMaximumLength; + } } catch (IOException) { diff --git a/src/CommandLine/Text/HelpText.cs b/src/CommandLine/Text/HelpText.cs index eaa6ade5..24dacbc2 100644 --- a/src/CommandLine/Text/HelpText.cs +++ b/src/CommandLine/Text/HelpText.cs @@ -105,6 +105,10 @@ public HelpText(SentenceBuilder sentenceBuilder, string heading, string copyrigh try { maximumDisplayWidth = Console.WindowWidth; + if (maximumDisplayWidth < 1) + { + maximumDisplayWidth = DefaultMaximumLength; + } } catch (IOException) {