From a3d0fd380fb9dfbb3665dd68f81155af8b3f00a5 Mon Sep 17 00:00:00 2001 From: Maxwell Huang-Hobbs Date: Mon, 28 Feb 2022 18:31:04 -0500 Subject: [PATCH] revert attempt at sequence compression + cursorUpBy --- screen.go | 4 ---- screen_test.go | 8 +------- standard_renderer.go | 12 +++--------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/screen.go b/screen.go index d05dbd10ba..63db7ae656 100644 --- a/screen.go +++ b/screen.go @@ -27,10 +27,6 @@ func cursorDown(w io.Writer) { fmt.Fprintf(w, te.CSI+te.CursorDownSeq, 1) } -func cursorUpBy(w io.Writer, count int) { - fmt.Fprintf(w, te.CSI+te.CursorUpSeq, count) -} - func insertLine(w io.Writer, numLines int) { fmt.Fprintf(w, te.CSI+"%dL", numLines) } diff --git a/screen_test.go b/screen_test.go index 335399df1d..7bfdf2e676 100644 --- a/screen_test.go +++ b/screen_test.go @@ -46,13 +46,7 @@ func TestScreen(t *testing.T) { exercise(t, cursorUp, []byte("\x1b[1A")) }) - t.Run("upBy", func(t *testing.T) { - exercise(t, func(w io.Writer) { - cursorUpBy(w, 3) - }, []byte("\x1b[3A")) - }) - - t.Run("downBy", func(t *testing.T) { + t.Run("down", func(t *testing.T) { exercise(t, cursorDown, []byte("\x1b[1B")) }) diff --git a/standard_renderer.go b/standard_renderer.go index 8efd56b822..2d12271ff5 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -138,23 +138,17 @@ func (r *standardRenderer) flush() { // Clear any lines we painted in the last render. if r.linesRendered > 0 { - jumpedLines := 0 for i := r.linesRendered - 1; i > 0; i-- { // If the number of lines we want to render hasn't increased and // new line is the same as the old line we can skip rendering for // this line as a performance optimization. if (len(newLines) <= len(oldLines)) && (len(newLines) > i && len(oldLines) > i) && (newLines[i] == oldLines[i]) { skipLines[i] = struct{}{} - jumpedLines++ - } else { - cursorUpBy(out, jumpedLines) + } else if _, exists := r.ignoreLines[i]; !exists { clearLine(out) - - jumpedLines = 0 } - } - if jumpedLines >= 1 { - cursorUpBy(out, jumpedLines+1) + + cursorUp(out) } if _, exists := r.ignoreLines[0]; !exists {