From fa36fb177ea4e865cc48ee70d9e26616df750b29 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 30 Oct 2025 12:36:21 -0400 Subject: [PATCH] fix: renderer: only move cursor to bottom when we're in the main screen --- cursed_renderer.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cursed_renderer.go b/cursed_renderer.go index d2587196..4a0306f5 100644 --- a/cursed_renderer.go +++ b/cursed_renderer.go @@ -137,9 +137,6 @@ func (s *cursedRenderer) close() (err error) { s.mu.Lock() defer s.mu.Unlock() - // Go to the bottom of the screen. - s.scr.MoveTo(0, s.buf.Height()-1) - // Exit the altScreen and show cursor before closing. It's important that // we don't change the [cursedRenderer] altScreen and cursorHidden states // so that we can restore them when we start the renderer again. This is @@ -148,6 +145,8 @@ func (s *cursedRenderer) close() (err error) { if lv.AltScreen { s.scr.ExitAltScreen() } else { + // Go to the bottom of the screen. + s.scr.MoveTo(0, s.buf.Height()-1) _, _ = s.scr.WriteString("\r" + ansi.EraseScreenBelow) } if lv.Cursor == nil { @@ -534,8 +533,8 @@ func (s *cursedRenderer) clearScreen() { s.mu.Lock() // Move the cursor to the top left corner of the screen and trigger a full // screen redraw. - _, _ = s.scr.WriteString(ansi.CursorHomePosition) - s.scr.Redraw(s.buf.Buffer) // force redraw + s.scr.MoveTo(0, 0) + s.scr.Erase() s.mu.Unlock() }