Skip to content

Commit a363079

Browse files
committed
progress needs to take in account situations where the cursor is not on the left edge (like when tables are being output)
1 parent 39be710 commit a363079

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ class ProgressPane
9191

9292
int rows = tempProgressRegion.GetLength(0);
9393
int cols = tempProgressRegion.GetLength(1);
94+
95+
_savedCursor = _rawui.CursorPosition;
9496
_location.X = 0;
9597

9698
#if UNIX
9799
_location.Y = _rawui.CursorPosition.Y;
98100

101+
// if cursor is not on left edge already move down one line
102+
if (_rawui.CursorPosition.X != 0)
103+
{
104+
_location.Y++;
105+
_rawui.CursorPosition = _location;
106+
}
107+
99108
//if the cursor is at the bottom, create screen buffer space by scrolling
100109
int scrollRows = rows - ((_rawui.BufferSize.Height - 1) - _location.Y);
101110
for (int i = 0; i < rows; i++)
@@ -105,6 +114,7 @@ class ProgressPane
105114
if (scrollRows > 0)
106115
{
107116
_location.Y -= scrollRows;
117+
_savedCursor.Y -= scrollRows;
108118
}
109119

110120
//create cleared region to clear progress bar later
@@ -161,6 +171,7 @@ class ProgressPane
161171

162172
_rawui.SetBufferContents(_location, _savedRegion);
163173
_savedRegion = null;
174+
_rawui.CursorPosition = _savedCursor;
164175
}
165176
}
166177

@@ -249,6 +260,7 @@ class ProgressPane
249260

250261

251262
private Coordinates _location = new Coordinates(0, 0);
263+
private Coordinates _savedCursor;
252264
private Size _bufSize;
253265
private BufferCell[,] _savedRegion;
254266
private BufferCell[,] _progressRegion;

0 commit comments

Comments
 (0)