Skip to content

Commit

Permalink
Check CursorTop before changing CursorLeft to prevent ArgumentOutOfRa…
Browse files Browse the repository at this point in the history
…ngeException (#3372)

* Catch ArgumentOutOfRangeException

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

* Check CursorTop before changing CursorLeft
  • Loading branch information
HJLeee authored Sep 14, 2022
1 parent 900eafb commit e4d0818
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Microsoft.Diagnostics.Repl/ConsoleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void ClearLine()

Console.Write(m_clearLine);

if (!m_outputRedirected) {
if (!m_outputRedirected && Console.CursorTop >= 0 ) {
Console.CursorLeft = 0;
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ private void PrintActiveLine()

Console.Write("{0}{1}", prompt, text);

if (!m_outputRedirected) {
if (!m_outputRedirected && Console.CursorTop >= 0) {
Console.CursorLeft = prompt.Length + (m_cursorPosition - m_scrollPosition);
}
}
Expand Down

0 comments on commit e4d0818

Please sign in to comment.