diff --git a/crates/prek/src/cli/reporter.rs b/crates/prek/src/cli/reporter.rs index 9562023f..49ea2f3b 100644 --- a/crates/prek/src/cli/reporter.rs +++ b/crates/prek/src/cli/reporter.rs @@ -36,6 +36,8 @@ pub(crate) fn suspend(f: impl FnOnce() + Send + 'static) { struct BarState { /// A map of progress bars, by ID. bars: FxHashMap, + /// Completed run bars that should stay visible until the current group is rendered. + completed: Vec, /// A monotonic counter for bar IDs. id: usize, } @@ -226,13 +228,27 @@ impl HookRunReporter { pub fn on_run_complete(&self, id: usize) { let progress = { let mut state = self.reporter.state.lock().unwrap(); - state.bars.remove(&id).unwrap() + let progress = state.bars.remove(&id).unwrap(); + state.completed.push(progress.clone()); + progress }; self.reporter.root.inc(1); - // Clear the running line; final output is printed by the caller. - progress.finish_and_clear(); + // Keep the finished line visible until the group result is rendered. + progress.set_position(progress.length().unwrap_or(1)); + progress.finish(); + } + + pub fn clear_completed(&self) { + let completed = { + let mut state = self.reporter.state.lock().unwrap(); + std::mem::take(&mut state.completed) + }; + + for progress in completed { + self.reporter.children.remove(&progress); + } } /// Temporarily suspend progress rendering while emitting normal output. @@ -243,6 +259,7 @@ impl HookRunReporter { } pub fn on_complete(&self) { + self.clear_completed(); self.reporter.on_complete(); } } diff --git a/crates/prek/src/cli/run/run.rs b/crates/prek/src/cli/run/run.rs index 872d6ca3..b335f901 100644 --- a/crates/prek/src/cli/run/run.rs +++ b/crates/prek/src/cli/run/run.rs @@ -661,6 +661,7 @@ async fn run_hooks( file_modified = true; } + reporter.clear_completed(); reporter.suspend(|| { render_priority_group( printer,