@@ -1450,6 +1450,32 @@ private void handleNonSeparatorEvent(final Event event, final SettingsValues set
14501450 mWordComposer .setCapitalizedModeAtStartComposingTime (inputTransaction .getShiftState ());
14511451 }
14521452 setComposingTextInternal (getTextWithUnderline (mWordComposer .getTypedWord ()), 1 );
1453+ if (helium314 .keyboard .latin .utils .TextExpanderUtils .INSTANCE .isEnabled (mLatinIME )
1454+ && helium314 .keyboard .latin .utils .TextExpanderUtils .INSTANCE .isImmediateEnabled (mLatinIME )) {
1455+ final String typedWord = mWordComposer .getTypedWord ();
1456+ final String prefix = helium314 .keyboard .latin .utils .TextExpanderUtils .INSTANCE .getPrefix (mLatinIME );
1457+ if (prefix .isEmpty ()) {
1458+ final String expanded = helium314 .keyboard .latin .utils .TextExpanderUtils .INSTANCE .getExpandedWord (typedWord , mLatinIME );
1459+ if (expanded != null ) {
1460+ commitExpandedText (typedWord , expanded );
1461+ resetComposingState (true );
1462+ }
1463+ } else {
1464+ final CharSequence textBefore = mConnection .getTextBeforeCursor (50 , 0 );
1465+ if (textBefore != null ) {
1466+ final String textStr = textBefore .toString ();
1467+ final String targetSuffix = prefix + typedWord ;
1468+ if (textStr .toLowerCase (java .util .Locale .US ).endsWith (targetSuffix .toLowerCase (java .util .Locale .US ))) {
1469+ final String expanded = helium314 .keyboard .latin .utils .TextExpanderUtils .INSTANCE .getExpandedWord (targetSuffix , mLatinIME );
1470+ if (expanded != null ) {
1471+ mConnection .deleteTextBeforeCursor (prefix .length ());
1472+ commitExpandedText (targetSuffix , expanded );
1473+ resetComposingState (true );
1474+ }
1475+ }
1476+ }
1477+ }
1478+ }
14531479 } else {
14541480 final boolean swapWeakSpace = tryStripSpaceAndReturnWhetherShouldSwapInstead (event , inputTransaction );
14551481
@@ -1640,7 +1666,7 @@ private void handleBackspaceEvent(final Event event, final InputTransaction inpu
16401666 final String expectedAfter = mLastExpandedText .substring (beforeLen );
16411667 if (textBefore != null && textBefore .toString ().equals (expectedBefore )
16421668 && textAfter != null && textAfter .toString ().equals (expectedAfter )) {
1643- mConnection .deleteSurroundingText ( beforeLen , afterLen );
1669+ mConnection .setSelection ( expectedCursor - beforeLen , expectedCursor + afterLen );
16441670 mConnection .commitText (mLastShortcutText , 1 );
16451671 mLastExpandedText = null ;
16461672 mLastShortcutText = null ;
0 commit comments