Skip to content

Commit ab4018d

Browse files
sbhusalmax-niederman
sbhusal
authored andcommitted
fix: fix terminal breaking on no invalid language
This commit fixes the terminal breaking on invalid language entry in config. Also, partialresult is removed as a part of linting.
1 parent 00ca3ae commit ab4018d

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/main.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ fn main() -> io::Result<()> {
218218

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

222225
terminal::enable_raw_mode()?;
223226
execute!(
@@ -228,13 +231,7 @@ fn main() -> io::Result<()> {
228231
)?;
229232
terminal.clear()?;
230233

231-
let mut state = State::Test(Test::new(
232-
opt.gen_contents().expect(
233-
"Couldn't get test contents. Make sure the specified language actually exists.",
234-
),
235-
!opt.no_backtrack,
236-
opt.sudden_death,
237-
));
234+
let mut state = State::Test(Test::new(contents, !opt.no_backtrack, opt.sudden_death));
238235

239236
state.render_into(&mut terminal, &config)?;
240237
loop {

src/test/results.rs

-13
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ impl fmt::Display for Fraction {
4343
}
4444
}
4545

46-
pub trait PartialResults {
47-
fn progress(&self) -> Fraction;
48-
}
49-
50-
impl PartialResults for Test {
51-
fn progress(&self) -> Fraction {
52-
Fraction {
53-
numerator: self.current_word + 1,
54-
denominator: self.words.len(),
55-
}
56-
}
57-
}
58-
5946
pub struct TimingData {
6047
// Instead of storing WPM, we store CPS (clicks per second)
6148
pub overall_cps: f64,

0 commit comments

Comments
 (0)