Check CursorTop before changing CursorLeft to prevent ArgumentOutOfRangeException...
authorHyungju Lee <leee.lee@samsung.com>
Wed, 14 Sep 2022 22:08:38 +0000 (07:08 +0900)
committerGitHub <noreply@github.com>
Wed, 14 Sep 2022 22:08:38 +0000 (15:08 -0700)
* Catch ArgumentOutOfRangeException

dotnet-dump analyze causes an Exception when console top is -1

* Check CursorTop before changing CursorLeft

src/Microsoft.Diagnostics.Repl/ConsoleService.cs

index c14fba57b7ced8c2a8cebed9e9d34f5b6b76dfc9..bb139a000cb0c56ee167cdf5164e056b3d9465de 100644 (file)
@@ -267,7 +267,7 @@ namespace Microsoft.Diagnostics.Repl
 
             Console.Write(m_clearLine);
 
-            if (!m_outputRedirected) {
+            if (!m_outputRedirected && Console.CursorTop >= 0 ) {
                 Console.CursorLeft = 0;
             }
         }
@@ -313,7 +313,7 @@ namespace Microsoft.Diagnostics.Repl
 
             Console.Write("{0}{1}", prompt, text);
 
-            if (!m_outputRedirected) {
+            if (!m_outputRedirected && Console.CursorTop >= 0) {
                 Console.CursorLeft = prompt.Length + (m_cursorPosition - m_scrollPosition);
             }
         }