Skip to content

Commit e08072d

Browse files
authored
Fix a rendering issue regarding cleanup of previous logical lines (#1865)
1 parent b33e222 commit e08072d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

PSReadLine/Render.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,22 @@ void UpdateColorsIfNecessary(string newColor)
760760
}
761761

762762
// Fewer logical lines than our previous render? Clear them.
763-
for (; previousLogicalLine < previousRenderLines.Length; previousLogicalLine++)
763+
for (int line = previousLogicalLine; line < previousRenderLines.Length; line++)
764764
{
765+
if (line > previousLogicalLine || logicalLineStartIndex < renderLines.Length)
766+
{
767+
// For the first of the remaining previous logical lines, if we didn't actually
768+
// render anything for the current logical lines, then the cursor is already at
769+
// the beginning of the right physical line that should be cleared, and thus no
770+
// need to write a new line in such case.
771+
// In other cases, we need to write a new line to get the cursor to the correct
772+
// physical line.
773+
774+
_console.Write("\n");
775+
}
776+
765777
// No need to write new line if all we need is to clear the extra previous render.
766-
if (logicalLineStartIndex < renderLines.Length) { _console.Write("\n"); }
767-
_console.Write(Spaces(previousRenderLines[previousLogicalLine].columns));
778+
_console.Write(Spaces(previousRenderLines[line].columns));
768779
}
769780

770781
// Preserve the current render data.

0 commit comments

Comments
 (0)