diff options
author | QMK Bot <hello@qmk.fm> | 2021-12-30 04:18:05 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-12-30 04:18:05 +0000 |
commit | 602b0b14d5d1b67951851c9880dc426411cc65d9 (patch) | |
tree | 7ebaa2f5bb8c1a7ac87f4be84ce88ba73cd3968e /users/drashna/keyrecords/autocorrection/autocorrection.c | |
parent | dde5cd1c54fc6f93ff439666f5c421a451e4e8dd (diff) | |
parent | c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users/drashna/keyrecords/autocorrection/autocorrection.c')
-rw-r--r-- | users/drashna/keyrecords/autocorrection/autocorrection.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c index 7c8c28c674..e561224374 100644 --- a/users/drashna/keyrecords/autocorrection/autocorrection.c +++ b/users/drashna/keyrecords/autocorrection/autocorrection.c @@ -1,5 +1,5 @@ // Copyright 2021 Google LLC -// Copyright 2022 @filterpaper +// Copyright 2021 @filterpaper // SPDX-License-Identifier: Apache-2.0 // Original source: https://getreuer.info/posts/keyboards/autocorrection @@ -7,10 +7,15 @@ #include <string.h> #if __has_include("autocorrection_data.h") +# pragma GCC push_options +# pragma GCC optimize("O0") # include "autocorrection_data.h" # if AUTOCORRECTION_MIN_LENGTH < 4 # error Minimum Length is too short and may cause overflows # endif +# if DICTIONARY_SIZE > SIZE_MAX +# error Dictionary size excees maximum size permitted +# endif bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC}; @@ -55,11 +60,17 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { } # endif default: + // Disable autocorrection while a mod other than shift is active. + if (((get_mods() | get_oneshot_mods()) & ~MOD_MASK_SHIFT) != 0) { + typo_buffer_size = 0; + return true; + } if (!record->event.pressed) { return true; } } + // Subtract buffer for Backspace key, reset for other non-alpha. if (!(KC_A <= keycode && keycode <= KC_Z)) { if (keycode == KC_BSPC) { @@ -137,6 +148,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { } return true; } +# pragma GCC pop_options #else # pragma message "Warning!!! Autocorrect is not corretly setup!" bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { return true; } |