From 11b98f776aefcbd87da1ca83347e816da4bfe2af Mon Sep 17 00:00:00 2001 From: Chris West Date: Sat, 20 Apr 2024 06:03:19 +0100 Subject: [PATCH] feat: under --clear reset, always reset at exit (#797) --- crates/cli/src/config.rs | 22 +++++++++++++--------- crates/cli/src/lib.rs | 5 +++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/cli/src/config.rs b/crates/cli/src/config.rs index 90668cd..87aaf15 100644 --- a/crates/cli/src/config.rs +++ b/crates/cli/src/config.rs @@ -114,15 +114,7 @@ pub fn make_config(args: &Args, state: &State) -> Result { clearscreen::clear().ok(); } ClearMode::Reset => { - for cs in [ - ClearScreen::WindowsCooked, - ClearScreen::WindowsVt, - ClearScreen::VtLeaveAlt, - ClearScreen::VtWellDone, - ClearScreen::default(), - ] { - cs.clear().ok(); - } + reset_screen(); } } } @@ -686,3 +678,15 @@ fn emit_events_to_command( command.stdin(stdin); } } + +pub(crate) fn reset_screen() { + for cs in [ + ClearScreen::WindowsCooked, + ClearScreen::WindowsVt, + ClearScreen::VtLeaveAlt, + ClearScreen::VtWellDone, + ClearScreen::default(), + ] { + cs.clear().ok(); + } +} diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index beca210..f328e6f 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -113,6 +113,11 @@ async fn run_watchexec(args: Args) -> Result<()> { info!("running main loop"); wx.main().await.into_diagnostic()??; + + if matches!(args.screen_clear, Some(args::ClearMode::Reset)) { + config::reset_screen(); + } + info!("done with main loop"); Ok(())