From 5d1a7264c5c58e7ef6ad56a888daadbcb602f26d Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Thu, 25 Aug 2022 19:18:06 +0200 Subject: [PATCH] fix: ensure alt screen switch always clears terminal --- standard_renderer.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/standard_renderer.go b/standard_renderer.go index 4edf214..4beaf3a 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -262,9 +262,17 @@ func (r *standardRenderer) enterAltScreen() { defer r.mtx.Unlock() r.altScreenActive = true - r.out.AltScreen() + + // Ensure that the terminal is cleared, even when it doesn't support + // alt screen (or alt screen support is disabled, like GNU screen by + // default). + // + // Note: we can't use r.clearScreen() here because the mutex is already + // locked. + r.out.ClearScreen() r.out.MoveCursor(1, 1) + r.repaint() } @@ -273,8 +281,8 @@ func (r *standardRenderer) exitAltScreen() { defer r.mtx.Unlock() r.altScreenActive = false - r.out.ExitAltScreen() + r.repaint() }