Skip to content

Commit 2d279f1

Browse files
authored
Merge pull request #16 from mayuki/hotfix/RedirectedConsole
Fix an error that occured when running in a redirected console
2 parents 7b3faa8 + b87b8fe commit 2d279f1

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<VersionPrefix>1.4.0</VersionPrefix>
4+
<VersionPrefix>1.4.1</VersionPrefix>
55
<LangVersion>latest</LangVersion>
66

77
<Authors>Mayuki Sawatari</Authors>

Kurukuru/Spinner.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,31 @@ private void Render(string terminator)
133133
{
134134
lock (Console.Out)
135135
{
136-
var currentLeft = Console.CursorLeft;
137-
var currentTop = Console.CursorTop;
138-
139-
ConsoleHelper.ClearCurrentConsoleLine(_lineLength, _enabled ? _cursorTop : currentTop);
140-
ConsoleHelper.WriteWithColor(frame, Color ?? Console.ForegroundColor);
141-
Console.Write(" ");
142-
Console.Write(Text);
143-
_lineLength = Console.CursorLeft; // get line length before write terminator
144-
Console.Write(terminator);
145-
Console.Out.Flush();
146-
147136
if (_enabled)
148137
{
138+
var currentLeft = Console.CursorLeft;
139+
var currentTop = Console.CursorTop;
140+
141+
ConsoleHelper.ClearCurrentConsoleLine(_lineLength, _enabled ? _cursorTop : currentTop);
142+
ConsoleHelper.WriteWithColor(frame, Color ?? Console.ForegroundColor);
143+
Console.Write(" ");
144+
Console.Write(Text);
145+
_lineLength = Console.CursorLeft; // get line length before write terminator
146+
Console.Write(terminator);
147+
Console.Out.Flush();
148+
149149
Console.SetCursorPosition(currentLeft, currentTop);
150150
}
151+
else
152+
{
153+
154+
ConsoleHelper.WriteWithColor(frame, Color ?? Console.ForegroundColor);
155+
Console.Write(" ");
156+
Console.Write(Text);
157+
_lineLength = frame.Length + 1 + Text.Length;
158+
Console.Write(terminator);
159+
Console.Out.Flush();
160+
}
151161
}
152162
}
153163
}

0 commit comments

Comments
 (0)