Skip to content

Commit

Permalink
Mitigation for AUTOCORRECTION_MIN_LENGTH < 4.
Browse files Browse the repository at this point in the history
Mitigates issue #2

@drashna observed autocorrection behaving badly when the min typo length
is less than 4, so this commit adds a compile-time check to prevent such
short lengths.
  • Loading branch information
getreuer committed Dec 14, 2021
1 parent da5aacd commit 31806d0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions features/autocorrection.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include <string.h>
#include "autocorrection_data.h"

#if AUTOCORRECTION_MIN_LENGTH < 4
// Odd output or hard locks on the board have been observed when the min typo
// length is 3 or lower (https://github.com/getreuer/qmk-keymap/issues/2).
// Additionally, autocorrection entries for short typos are more likely to false
// trigger, so it is suggested that typos be at least 5 characters.
#error "Min typo length is less than 4. Autocorrection may behave poorly."
#endif

bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {0};
static uint8_t typo_buffer_size = 0;
Expand Down

0 comments on commit 31806d0

Please sign in to comment.