Skip to content

Commit

Permalink
fix: fix terminal breaking on no invalid language
Browse files Browse the repository at this point in the history
This commit fixes the terminal breaking on invalid language entry in
config. Also, partialresult is removed as a part of linting.
  • Loading branch information
sbhusal authored and max-niederman committed Sep 23, 2024
1 parent 00ca3ae commit ab4018d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
11 changes: 4 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ fn main() -> io::Result<()> {

let backend = CrosstermBackend::new(io::stdout());
let mut terminal = Terminal::new(backend)?;
let contents = opt
.gen_contents()
.expect("Couldn't get test contents. Make sure the specified language actually exists.");

terminal::enable_raw_mode()?;
execute!(
Expand All @@ -228,13 +231,7 @@ fn main() -> io::Result<()> {
)?;
terminal.clear()?;

let mut state = State::Test(Test::new(
opt.gen_contents().expect(
"Couldn't get test contents. Make sure the specified language actually exists.",
),
!opt.no_backtrack,
opt.sudden_death,
));
let mut state = State::Test(Test::new(contents, !opt.no_backtrack, opt.sudden_death));

state.render_into(&mut terminal, &config)?;
loop {
Expand Down
13 changes: 0 additions & 13 deletions src/test/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ impl fmt::Display for Fraction {
}
}

pub trait PartialResults {
fn progress(&self) -> Fraction;
}

impl PartialResults for Test {
fn progress(&self) -> Fraction {
Fraction {
numerator: self.current_word + 1,
denominator: self.words.len(),
}
}
}

pub struct TimingData {
// Instead of storing WPM, we store CPS (clicks per second)
pub overall_cps: f64,
Expand Down

0 comments on commit ab4018d

Please sign in to comment.