Skip to content

Commit dff21d6

Browse files
committed
Treat dash as a non-autocorrectable separator
1 parent 9c5b5a2 commit dff21d6

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

java/res/values-fr-rCA/donottranslate-config-spacing-and-punctuations.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<string name="symbols_followed_by_space">.,;:!?)]}</string>
2626
<!-- Symbols that separate words -->
2727
<!-- Don't remove the enclosing double quotes, they protect whitespace (not just U+0020) -->
28-
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"</string>
28+
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"-</string>
2929
<!-- Word connectors -->
30-
<string name="symbols_word_connectors">\'-</string>
30+
<string name="symbols_word_connectors">\'</string>
3131
</resources>

java/res/values-fr/donottranslate-config-spacing-and-punctuations.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<string name="symbols_clustering_together">!?</string>
2727
<!-- Symbols that separate words -->
2828
<!-- Don't remove the enclosing double quotes, they protect whitespace (not just U+0020) -->
29-
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"</string>
29+
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"-</string>
3030
<!-- Word connectors -->
31-
<string name="symbols_word_connectors">\'-</string>
31+
<string name="symbols_word_connectors">\'</string>
3232
</resources>

java/res/values-hy/donottranslate-config-spacing-and-punctuations.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<string name="symbols_followed_by_space">.,;:!?)]}&#x0589;&#x055D;</string>
2626
<!-- Symbols that separate words. Adding armenian period and comma. -->
2727
<!-- Don't remove the enclosing double quotes, they protect whitespace (not just U+0020) -->
28-
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"&#x0589;&#x055D;</string>
28+
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"&#x0589;&#x055D;-</string>
2929
<!-- The sentence separator code point, for capitalization -->
3030
<!-- U+0589: "։" ARMENIAN FULL STOP ; 589h = 1417d -->
3131
<integer name="sentence_separator">1417</integer>

java/res/values/donottranslate-config-spacing-and-punctuations.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
<string name="symbols_clustering_together"></string>
3535
<!-- Symbols that separate words -->
3636
<!-- Don't remove the enclosing double quotes, they protect whitespace (not just U+0020) -->
37-
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"</string>
37+
<string name="symbols_word_separators">"&#x0009;&#x0020;&#x000A;&#x00A0;"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"-</string>
3838
<!-- Word connectors -->
39-
<string name="symbols_word_connectors">\'-</string>
39+
<string name="symbols_word_connectors">\'</string>
4040
<!-- The sentence separator code point, for capitalization and auto-insertion -->
4141
<!-- U+002E: "." FULL STOP ; 2Eh = 46d -->
4242
<integer name="sentence_separator">46</integer>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ public static SuggestedWords obtainNonBatchedInputSuggestedWords(
306306
false /* isObsoleteSuggestions */, inputStyle, sequenceNumber);
307307
}
308308

309+
// Returns whether the provided codepoint should trigger an autocorrection
310+
public static boolean shouldCodePointAutocorrect(final int codePoint) {
311+
// Dash will never autocorrect because the autocorrect currently doesn't take the dash
312+
// suffix into account, this leads to it miscorrecting prefixes like "un-" to "in-"
313+
// because in most cases, "un" is a typo of "in"
314+
return codePoint != '-';
315+
}
316+
309317

310318
// Retrieves suggestions for non-batch input (typing, recorrection, predictions...)
311319
// and calls the callback function with the suggestions.

java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,8 @@ private void handleSeparatorEvent(final Event event, final InputTransaction inpu
10371037
}
10381038
// isComposingWord() may have changed since we stored wasComposing
10391039
if (mWordComposer.isComposingWord()) {
1040-
if (settingsValues.mAutoCorrectionEnabledPerUserSettings) {
1040+
if (settingsValues.mAutoCorrectionEnabledPerUserSettings
1041+
&& Suggest.shouldCodePointAutocorrect(codePoint)) {
10411042
final String separator = shouldAvoidSendingCode ? LastComposedWord.NOT_A_SEPARATOR
10421043
: StringUtils.newSingleCodePointString(codePoint);
10431044
commitCurrentAutoCorrection(settingsValues, separator);

0 commit comments

Comments
 (0)