Repository: spectreconsole/spectre.console

Issue:
Blatant flickering
**Information**
 - OS: Windows 10/11
 - Version: 0.48.0
 - Terminal: Dos Prompt, Powershell and Windows Terminal

**Describe the bug**
Displaying a task list with spinners causes the whole task list to flicker. Apparently, see below, this is a regression introduced in 0.48.0

**To Reproduce**
The following code exhibits the issue: (tested on .net 6.0 and .net 8.0)
```c#
using Spectre.Console;

namespace TestConsole
{
    internal static class Program
    {
        private static async Task LoopAsync(ProgressTask task)
        {
            await Task.Yield();

            for (int i = 0; i < 100; i++)
            {
                task.Increment(1);
                await Task.Delay(TimeSpan.FromSeconds(4)).ConfigureAwait(false);
            }
        }

        private static async Task Main()
        {
            Console.WriteLine("Flickering Test");

            var progress = AnsiConsole.Progress()
              .AutoRefresh(true)
              .AutoClear(false)
              .HideCompleted(false)
              .Columns(
              [
                  new TaskDescriptionColumn(),
                  new ProgressBarColumn(),
                  new PercentageColumn(),
                  new RemainingTimeColumn(),
                  new SpinnerColumn(Spinner.Known.Dots),
              ]);

            await progress.StartAsync(async x =>
            {
                var tasks = new List<Task>();
                for (int i = 0; i < 10; i++)
                {
                    var t = x.AddTask($"Task {i}", true, 100);
                    tasks.Add(LoopAsync(t));
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);
            }).ConfigureAwait(false);
        }
    }
}

```
**Expected behavior**
No flickering, like in 0.47.0

**Screenshots**
**0.48.0**:
![Flickering](https://github.com/spectreconsole/spectre.console/assets/5850742/bd26b8a6-0ea0-4905-92d2-52e9186c4e92)
**0.47.0**:
![NoFlickering](https://github.com/spectreconsole/spectre.console/assets/5850742/a9efe7e1-0b35-472c-9d2b-d03027633ecc)


**Additional context**
The "regression" has been introduced in the commit https://github.com/spectreconsole/spectre.console/commit/71a5d830671220e601e4e6ab4d4c352ae0e0a64a

The offending line is in src/Spectre.Console/Live/LiveRenderable.cs:

```diff
-            return new ControlCode("\r" + CUU(linesToMoveUp));
+            return new ControlCode("\r" + (EL(2) + CUU(1)).Repeat(linesToMoveUp));
```


Hints:
This is also happening for other widget types in `0.48` including up to at least `0.48.1-preview.0.32` in Windows terminal

https://github.com/spectreconsole/spectre.console/assets/13159458/f2783bb7-08c5-49cd-a097-4bc06e78bea5
This happens in progress displays without spinners as well.
Can confirm what @yenneferofvengerberg posted, rolling back that commit related to long lines smooths things out again. 

Probably need something a bit more clever than brute forcing a clear on each line each render. I'd almost be inclined to suggest using the `RenderHook` that now exists on `LiveRenderables` as the mechanism for including extra info while a progress is running rather than write line. Gives us a bit more control over the whole process too
Is there a PR to roll this back?
I considered doing it, but I couldn't figure out how to maintain the
correct behavior when the text goes out of screen. If someone can provide
me a hint, I would be happy to try
Since it's a regression I would say that it's OK with restoring it how it was, and look at finding a solution for it later.

Patch:
diff --git a/src/Spectre.Console/Live/LiveRenderable.cs b/src/Spectre.Console/Live/LiveRenderable.cs
index a681d2405..40107f9cd 100644
--- a/src/Spectre.Console/Live/LiveRenderable.cs
+++ b/src/Spectre.Console/Live/LiveRenderable.cs
@@ -49,7 +49,7 @@ public IRenderable PositionCursor()
             }
 
             var linesToMoveUp = _shape.Value.Height - 1;
-            return new ControlCode("\r" + (EL(2) + CUU(1)).Repeat(linesToMoveUp));
+            return new ControlCode("\r" + CUU(linesToMoveUp));
         }
     }
 


Test patch:
diff --git a/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt
index cd5fed942..debe2399d 100644
--- a/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt
+++ b/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt
@@ -1,10 +1,10 @@
 [?25l     
 [38;5;11m*[0m foo
      
-[2K[1A[2K[1A     
+[2A     
 [38;5;11m-[0m bar
      
-[2K[1A[2K[1A     
+[2A     
 [38;5;11m*[0m baz
      
 [2K[1A[2K[1A[2K[?25h
\ No newline at end of file
diff --git a/test/Spectre.Console.Tests/Expectations/Live/Status/WriteLineOverflow.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Live/Status/WriteLineOverflow.Output.verified.txt
deleted file mode 100644
index d3647bb50..000000000
--- a/test/Spectre.Console.Tests/Expectations/Live/Status/WriteLineOverflow.Output.verified.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-﻿[?25l                                                    
-[38;5;11m⣷[0m long text that should not interfere writeline text
-                                                    
-[2K[1A[2K[1A[38;5;15mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[0m
-[38;5;15mxxxxxxxxxx[0m
-                                                    
-[38;5;11m⣷[0m long text that should not interfere writeline text
-                                                    
-[2K[1A[2K[1A                                                    
-[38;5;11m⣷[0m long text that should not interfere writeline text
-                                                    
-[2K[1A[2K[1A[2K[?25h
\ No newline at end of file
diff --git a/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs b/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs
index b80c5d0d1..a9510ad89 100644
--- a/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs
+++ b/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs
@@ -48,30 +48,4 @@ public Task Should_Render_Status_Correctly()
         // Then
         return Verifier.Verify(console.Output);
     }
-
-    [Fact]
-    [Expectation("WriteLineOverflow")]
-    public Task Should_Render_Correctly_When_WriteLine_Exceeds_Console_Width()
-    {
-        // Given
-        var console = new TestConsole()
-            .Colors(ColorSystem.TrueColor)
-            .Width(100)
-            .Interactive()
-            .EmitAnsiSequences();
-        var status = new Status(console)
-        {
-            AutoRefresh = false,
-        };
-
-        // When
-        status.Start("long text that should not interfere writeline text", ctx =>
-        {
-            ctx.Refresh();
-            console.WriteLine("x".Repeat(console.Profile.Width + 10), new Style(foreground: Color.White));
-        });
-
-        // Then
-        return Verifier.Verify(console.Output);
-    }
 }