Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt
// Update the progress pane only when the timer set up the update flag or WriteProgress is completed.
// As a result, we do not block WriteProgress and whole script and eliminate unnecessary console locks and updates.
_progPane.Show(_pendingProgress);

// Reset the cursor back to where it started
if (record.RecordType == ProgressRecordType.Completed)
{
_progPane.Hide();
}
}
}

Expand Down
16 changes: 12 additions & 4 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,20 @@ class ProgressPane

//if the cursor is at the bottom, create screen buffer space by scrolling
int scrollRows = rows - ((_rawui.BufferSize.Height - 1) - _location.Y);
for (int i = 0; i < rows; i++)
{
Console.Out.Write('\n');
}
if (scrollRows > 0)
{
// The following can be possibly replaced by Console.Write ("\x1b[" + scrollRows + "S");
// For details, see https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

// Scroll the console screen up by 'scrollRows'
var bottomLocation = _location;
bottomLocation.Y = _rawui.BufferSize.Height;
_rawui.CursorPosition = bottomLocation;
for (int i = 0; i < scrollRows; i++)
{
Console.Out.Write('\n');
}

_location.Y -= scrollRows;
_savedCursor.Y -= scrollRows;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ internal void ThrowIfWriteNotPermitted(bool needsToWriteToPipeline)
{
// Only generate these exceptions if a pipeline has already been declared as the 'writing' pipeline.
// Otherwise, these are probably infrastructure messages and can be ignored.
if (this.PipelineProcessor._permittedToWrite != null)
if (this.PipelineProcessor?._permittedToWrite != null)
{
throw PSTraceSource.NewInvalidOperationException(
PipelineStrings.WriteNotPermitted);
Expand Down