There is something akin to off-by one error, where first line disappears one line break too early, you can see it in the video. It really triggers my OCD
Fixed it locally like that:
private string CutViewport(int height, string lines)
{
string output = "";
int rowCount = 0;
for (int i = lines.Length - 1; i >= 0; i--)
{
if (lines[i] == '\n')
{
rowCount++;
}
if (rowCount > height)
{
return output;
}
output = lines[i] + output;
}
return output;
}