aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJoris2023-07-15 10:30:29 +0200
committerJoris2023-07-15 10:30:29 +0200
commitbd758850ab0b891d7fb61a7d043672cf8e337c94 (patch)
tree933abc2d4df75a939c1392adba49d553de8c3ca2 /src/gui
parent8fb457d5639d11d5075d664001e98148e223f257 (diff)
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.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/question.rs11
1 files 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<B: Backend>(terminal: &mut Terminal<B>, 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 }
}