Program: 157320
Project: 157320
Buggy source:
private void handleCharacter(final int primaryCode,final Key key,final int multiTapIndex,int[] nearByKeyCodes){
  if (BuildConfig.DEBUG)   Logger.d(TAG,"String_Node_Str",primaryCode,isPredictionOn(),mPredicting);
  mExpectingSelectionUpdateBy=SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE;
  if (!mPredicting && isPredictionOn() && isAlphabet(primaryCode)&& !isCursorTouchingWord()) {
    mPredicting=true;
    mUndoCommitCursorPosition=UNDO_COMMIT_NONE;
    mWord.reset();
    mAutoCorrectOn=mAutoComplete;
  }
  mLastCharacterWasShifted=(getInputView() != null) && getInputView().isShifted();
  final int primaryCodeToOutput;
  if (mShiftKeyState.isActive()) {
    if (key != null) {
      primaryCodeToOutput=key.getCodeAtIndex(multiTapIndex,true);
    }
 else {
      primaryCodeToOutput=Character.toUpperCase(primaryCode);
    }
  }
 else {
    primaryCodeToOutput=primaryCode;
  }
  if (mPredicting) {
    if (mShiftKeyState.isActive() && mWord.cursorPosition() == 0) {
      mWord.setFirstCharCapitalized(true);
    }
    final InputConnection ic=getCurrentInputConnection();
    mWord.add(primaryCodeToOutput,nearByKeyCodes);
    ChewbaccaOnTheDrums.onKeyTyped(mWord,getApplicationContext());
    if (ic != null) {
      final int cursorPosition;
      if (mWord.cursorPosition() != mWord.length()) {
        cursorPosition=mGlobalCursorPosition + 1;
        ic.beginBatchEdit();
      }
 else {
        cursorPosition=-1;
      }
      ic.setComposingText(mWord.getTypedWord(),1);
      if (cursorPosition > 0) {
        ic.setSelection(cursorPosition,cursorPosition);
        ic.endBatchEdit();
      }
    }
    if (isSuggestionAffectingCharacter(primaryCodeToOutput)) {
      postUpdateSuggestions();
    }
 else {
      if (mCandidateView != null)       mCandidateView.replaceTypedWord(mWord.getTypedWord());
    }
  }
 else {
    sendKeyChar((char)primaryCodeToOutput);
  }
  TextEntryState.typedCharacter((char)primaryCodeToOutput,false);
  mJustAutoAddedWord=false;
}

Fixed version (ground truth):
private void handleCharacter(final int primaryCode,final Key key,final int multiTapIndex,int[] nearByKeyCodes){
  if (BuildConfig.DEBUG)   Logger.d(TAG,"String_Node_Str",primaryCode,isPredictionOn(),mPredicting);
  mExpectingSelectionUpdateBy=SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE;
  if (!mPredicting && isPredictionOn() && isAlphabet(primaryCode)&& !isCursorTouchingWord()) {
    mPredicting=true;
    mUndoCommitCursorPosition=UNDO_COMMIT_NONE;
    mWord.reset();
    mAutoCorrectOn=mAutoComplete;
  }
  mLastCharacterWasShifted=(getInputView() != null) && getInputView().isShifted();
  if (mPredicting) {
    if (mShiftKeyState.isActive() && mWord.cursorPosition() == 0) {
      mWord.setFirstCharCapitalized(true);
    }
    final InputConnection ic=getCurrentInputConnection();
    mWord.add(primaryCode,nearByKeyCodes);
    ChewbaccaOnTheDrums.onKeyTyped(mWord,getApplicationContext());
    if (ic != null) {
      final int cursorPosition;
      if (mWord.cursorPosition() != mWord.length()) {
        cursorPosition=mGlobalCursorPosition + 1;
        ic.beginBatchEdit();
      }
 else {
        cursorPosition=-1;
      }
      ic.setComposingText(mWord.getTypedWord(),1);
      if (cursorPosition > 0) {
        ic.setSelection(cursorPosition,cursorPosition);
        ic.endBatchEdit();
      }
    }
    if (isSuggestionAffectingCharacter(primaryCode)) {
      postUpdateSuggestions();
    }
 else {
      if (mCandidateView != null)       mCandidateView.replaceTypedWord(mWord.getTypedWord());
    }
  }
 else {
    sendKeyChar((char)primaryCode);
  }
  TextEntryState.typedCharacter((char)primaryCode,false);
  mJustAutoAddedWord=false;
}