From c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 29 Dec 2021 20:17:34 -0800 Subject: [Keymap] Reorganization, cleanup and readmes for drashna code (#15617) --- users/drashna/keyrecords/autocorrection/autocorrection.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'users/drashna/keyrecords/autocorrection/autocorrection.c') 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 #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; } -- cgit v1.2.3