From ddab52b1a3e874c10638853cca25fa8c97127345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20St=C3=A9phenne?= Date: Tue, 16 Jun 2026 13:14:53 -0400 Subject: [PATCH] Clearing terminal before first draw --- src/main.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index eccd0b2..98032de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,17 +23,20 @@ fn main() -> color_eyre::Result<()> { color_eyre::install()?; let args = args::Args::parse(); - let mut textarea = match File::open(&args.file) { - Ok(file) => BufReader::new(file) - .lines() - .collect::>()?, + let textarea = match File::open(&args.file) { + Ok(file) => { + let mut textarea = BufReader::new(file) + .lines() + .collect::>()?; + textarea.move_cursor(CursorMove::Bottom); + textarea.move_cursor(CursorMove::End); + textarea.insert_newline(); + textarea.move_cursor(CursorMove::Top); + textarea + } Err(err) if err.kind() == io::ErrorKind::NotFound => TextArea::default(), Err(err) => return Err(err.into()), }; - textarea.move_cursor(CursorMove::Bottom); - textarea.move_cursor(CursorMove::End); - textarea.insert_newline(); - textarea.move_cursor(CursorMove::Top); let mut terminal = ratatui::init_with_options(TerminalOptions { viewport: if args.fullscreen { @@ -46,6 +49,7 @@ fn main() -> color_eyre::Result<()> { ) }, }); + terminal.clear()?; let cursor_pos = terminal.get_cursor_position()?; if args.fullscreen { execute!(stdout(), EnterAlternateScreen)?; -- 2.51.2