Skip to content

Commit 545facf

Browse files
committed
Do not autocorrect ordinals
1 parent a739d60 commit 545facf

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

java/src/org/futo/inputmethod/latin/Suggest.java

+2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ public static SuggestedWords obtainNonBatchedInputSuggestedWords(
210210
// If the word is entirely digits, never autocorrect regardless of number row
211211
// being active or not
212212
|| wordComposer.isEntirelyDigits()
213+
// If it's an ordinal (1st, 2nd, 3rd), do not autocorrect
214+
|| wordComposer.isOrdinal(locale)
213215
// If the word is mostly caps, we never auto-correct because this is almost
214216
// certainly intentional (and careful input)
215217
|| wordComposer.isMostlyCaps()

java/src/org/futo/inputmethod/latin/WordComposer.java

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import java.util.ArrayList;
3232
import java.util.Collections;
33+
import java.util.Locale;
3334

3435
import javax.annotation.Nonnull;
3536

@@ -361,6 +362,16 @@ public boolean isEntirelyDigits() {
361362
return mDigitsCount == mCodePointSize;
362363
}
363364

365+
/**
366+
* Returns true if the composing word is an ordinal
367+
*/
368+
public boolean isOrdinal(Locale locale) {
369+
final String word = getTypedWord();
370+
371+
// TODO: This is English-only
372+
return word.matches("^(\\d+)(st|nd|rd|th)$");
373+
}
374+
364375
/**
365376
* Saves the caps mode at the start of composing.
366377
*

0 commit comments

Comments
 (0)