Program: 87891
Project: 87891
Buggy source:
@Override public void onCodeInput(int primaryCode,int x,int y){
  final long when=SystemClock.uptimeMillis();
  if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
    mDeleteCount=0;
  }
  mLastKeyTime=when;
  mConnection.beginBatchEdit(getCurrentInputConnection());
  if (ProductionFlag.IS_EXPERIMENTAL) {
    ResearchLogger.latinIME_onCodeInput(primaryCode,x,y);
  }
  final KeyboardSwitcher switcher=mKeyboardSwitcher;
  final int spaceState=mSpaceState;
  if (!mWordComposer.isComposingWord())   mIsAutoCorrectionIndicatorOn=false;
  if (primaryCode != Keyboard.CODE_SPACE) {
    mHandler.cancelDoubleSpacesTimer();
  }
  boolean didAutoCorrect=false;
switch (primaryCode) {
case Keyboard.CODE_DELETE:
    mSpaceState=SPACE_STATE_NONE;
  handleBackspace(spaceState);
mDeleteCount++;
mExpectingUpdateSelection=true;
mShouldSwitchToLastSubtype=true;
LatinImeLogger.logOnDelete(x,y);
break;
case Keyboard.CODE_SHIFT:
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
break;
case Keyboard.CODE_SETTINGS:
onSettingsKeyPressed();
break;
case Keyboard.CODE_SHORTCUT:
mSubtypeSwitcher.switchToShortcutIME();
break;
case Keyboard.CODE_ACTION_ENTER:
performEditorAction(getActionId(switcher.getKeyboard()));
break;
case Keyboard.CODE_ACTION_NEXT:
performEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
case Keyboard.CODE_ACTION_PREVIOUS:
performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
break;
case Keyboard.CODE_LANGUAGE_SWITCH:
handleLanguageSwitchKey();
break;
case Keyboard.CODE_RESEARCH:
if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.getInstance().presentResearchDialog(this);
}
break;
default :
mSpaceState=SPACE_STATE_NONE;
if (mCurrentSettings.isWordSeparator(primaryCode)) {
didAutoCorrect=handleSeparator(primaryCode,x,y,spaceState);
}
 else {
final Keyboard keyboard=mKeyboardSwitcher.getKeyboard();
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
handleCharacter(primaryCode,x,y,spaceState);
}
 else {
handleCharacter(primaryCode,NOT_A_TOUCH_COORDINATE,NOT_A_TOUCH_COORDINATE,spaceState);
}
}
mExpectingUpdateSelection=true;
mShouldSwitchToLastSubtype=true;
break;
}
switcher.onCodeInput(primaryCode);
if (!didAutoCorrect && primaryCode != Keyboard.CODE_SHIFT && primaryCode != Keyboard.CODE_SWITCH_ALPHA_SYMBOL) mLastComposedWord.deactivate();
mEnteredText=null;
mConnection.endBatchEdit();
}

Fixed version (ground truth):
@Override public void onCodeInput(int primaryCode,int x,int y){
  final long when=SystemClock.uptimeMillis();
  if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
    mDeleteCount=0;
  }
  mLastKeyTime=when;
  mConnection.beginBatchEdit();
  if (ProductionFlag.IS_EXPERIMENTAL) {
    ResearchLogger.latinIME_onCodeInput(primaryCode,x,y);
  }
  final KeyboardSwitcher switcher=mKeyboardSwitcher;
  final int spaceState=mSpaceState;
  if (!mWordComposer.isComposingWord())   mIsAutoCorrectionIndicatorOn=false;
  if (primaryCode != Keyboard.CODE_SPACE) {
    mHandler.cancelDoubleSpacesTimer();
  }
  boolean didAutoCorrect=false;
switch (primaryCode) {
case Keyboard.CODE_DELETE:
    mSpaceState=SPACE_STATE_NONE;
  handleBackspace(spaceState);
mDeleteCount++;
mExpectingUpdateSelection=true;
mShouldSwitchToLastSubtype=true;
LatinImeLogger.logOnDelete(x,y);
break;
case Keyboard.CODE_SHIFT:
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
break;
case Keyboard.CODE_SETTINGS:
onSettingsKeyPressed();
break;
case Keyboard.CODE_SHORTCUT:
mSubtypeSwitcher.switchToShortcutIME();
break;
case Keyboard.CODE_ACTION_ENTER:
performEditorAction(getActionId(switcher.getKeyboard()));
break;
case Keyboard.CODE_ACTION_NEXT:
performEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
case Keyboard.CODE_ACTION_PREVIOUS:
performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
break;
case Keyboard.CODE_LANGUAGE_SWITCH:
handleLanguageSwitchKey();
break;
case Keyboard.CODE_RESEARCH:
if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.getInstance().presentResearchDialog(this);
}
break;
default :
mSpaceState=SPACE_STATE_NONE;
if (mCurrentSettings.isWordSeparator(primaryCode)) {
didAutoCorrect=handleSeparator(primaryCode,x,y,spaceState);
}
 else {
final Keyboard keyboard=mKeyboardSwitcher.getKeyboard();
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
handleCharacter(primaryCode,x,y,spaceState);
}
 else {
handleCharacter(primaryCode,NOT_A_TOUCH_COORDINATE,NOT_A_TOUCH_COORDINATE,spaceState);
}
}
mExpectingUpdateSelection=true;
mShouldSwitchToLastSubtype=true;
break;
}
switcher.onCodeInput(primaryCode);
if (!didAutoCorrect && primaryCode != Keyboard.CODE_SHIFT && primaryCode != Keyboard.CODE_SWITCH_ALPHA_SYMBOL) mLastComposedWord.deactivate();
mEnteredText=null;
mConnection.endBatchEdit();
}