fix: renderer: only move cursor to bottom when we're in the main screen

This commit is contained in:
Ayman Bagabas 2025-10-30 12:36:21 -04:00
parent d7c95b8a27
commit fa36fb177e
No known key found for this signature in database
GPG key ID: C8D51D2157C919AC

View file

@ -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()
}