From bd758850ab0b891d7fb61a7d043672cf8e337c94 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 15 Jul 2023 10:30:29 +0200 Subject: Default to good answer when pressing enter with empty answer When I don’t want to type answers, I am more often right than wrong, so it’s a better default to consider the answer to be right on empty input. --- src/gui/question.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/question.rs b/src/gui/question.rs index 12ffa6f..512ca49 100644 --- a/src/gui/question.rs +++ b/src/gui/question.rs @@ -129,9 +129,14 @@ pub fn ask(terminal: &mut Terminal, title: &str, card: &Card) -> match state.answer { Answer::Write => match key.code { KeyCode::Enter => { - let difficulty = match check_response(&state.input, &card.responses) { - CheckResponse::Correct { phonetics: _ } => Difficulty::Good, - CheckResponse::Incorrect => Difficulty::Again, + let difficulty = if state.input.is_empty() { + // Encourage solving without typing by defaulting to good answer + Difficulty::Good + } else { + match check_response(&state.input, &card.responses) { + CheckResponse::Correct { phonetics: _ } => Difficulty::Good, + CheckResponse::Incorrect => Difficulty::Again, + } }; state.answer = Answer::Difficulty { difficulty } } -- cgit v1.2.3