don't clear screen on startup (#3925)

This commit is contained in:
Jeremy Rose 2025-09-19 14:22:58 -07:00 committed by GitHub
parent ff389dc52f
commit ad0c2b4db3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,7 +14,7 @@ use std::time::Instant;
use crossterm::Command;
use crossterm::SynchronizedUpdate;
use crossterm::cursor;
#[cfg(unix)]
use crossterm::cursor::MoveTo;
use crossterm::event::DisableBracketedPaste;
use crossterm::event::DisableFocusChange;
@ -27,7 +27,6 @@ use crossterm::event::PopKeyboardEnhancementFlags;
use crossterm::event::PushKeyboardEnhancementFlags;
use crossterm::terminal::EnterAlternateScreen;
use crossterm::terminal::LeaveAlternateScreen;
use crossterm::terminal::ScrollUp;
use ratatui::backend::Backend;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::execute;
@ -127,15 +126,6 @@ pub fn init() -> Result<Terminal> {
set_panic_hook();
// Instead of clearing the screen (which can drop scrollback in some terminals),
// scroll existing lines up until the cursor reaches the top, then start at (0, 0).
if let Ok((_x, y)) = cursor::position()
&& y > 0
{
execute!(stdout(), ScrollUp(y))?;
}
execute!(stdout(), MoveTo(0, 0))?;
let backend = CrosstermBackend::new(stdout());
let tui = CustomTerminal::with_options(backend)?;
Ok(tui)