From 240dde2cc7fb3597cbb6e18b1294edde50cac2c2 Mon Sep 17 00:00:00 2001 From: Mroik Date: Tue, 28 Jan 2025 00:28:56 +0100 Subject: Print WPM only if completed the test --- src/app.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 5ad4f9e..79a82cf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -35,6 +35,7 @@ pub struct App { state: State, should_render: bool, start: Option, + completed: bool, } impl App { @@ -53,6 +54,7 @@ impl App { state: State::default(), should_render: true, start: None, + completed: false, } } @@ -85,7 +87,9 @@ impl App { disable_raw_mode()?; self.stdout.execute(LeaveAlternateScreen)?; - println!("Your WPM: {}", wpm.round()); + if self.completed { + println!("Your WPM: {}", wpm.round()); + } return Ok(()); } @@ -111,6 +115,7 @@ impl App { self.state.buffer.clear(); self.state.current += 1; if self.state.current == self.quote.len() { + self.completed = true; self.running = false; } } else { -- cgit v1.3