[ty] clear the terminal screen in watch mode (#19712)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
Leandro Braga 2025-08-04 08:45:37 -03:00 committed by GitHub
parent f473f6b6e5
commit de77b29798
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 0 deletions

1
Cargo.lock generated
View file

@ -4186,6 +4186,7 @@ dependencies = [
"argfile",
"clap",
"clap_complete_command",
"clearscreen",
"colored 3.0.0",
"crossbeam",
"ctrlc",

View file

@ -25,6 +25,7 @@ anyhow = { workspace = true }
argfile = { workspace = true }
clap = { workspace = true, features = ["wrap_help", "string", "env"] }
clap_complete_command = { workspace = true }
clearscreen = { workspace = true }
colored = { workspace = true }
crossbeam = { workspace = true }
ctrlc = { version = "3.4.4" }

View file

@ -261,6 +261,9 @@ impl MainLoop {
let mut revision = 0u64;
while let Ok(message) = self.receiver.recv() {
if self.watcher.is_some() {
Printer::clear_screen()?;
}
match message {
MainLoopMessage::CheckWorkspace => {
let db = db.clone();

View file

@ -1,5 +1,6 @@
use std::io::StdoutLock;
use anyhow::Result;
use indicatif::ProgressDrawTarget;
use crate::logging::VerbosityLevel;
@ -101,6 +102,11 @@ impl Printer {
pub(crate) fn stream_for_details(self) -> Stdout {
self.stdout_general()
}
pub(crate) fn clear_screen() -> Result<()> {
clearscreen::clear()?;
Ok(())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]