Program: 157281
Project: 157281
Buggy source:
private void handleSeparator(int primaryCode){
  if (!getCurrentAlphabetKeyboard().isLeftToRightLanguage()) {
    if (primaryCode == (int)')')     primaryCode=(int)'(';
 else     if (primaryCode == (int)'(')     primaryCode=(int)')';
  }
  mExpectingSelectionUpdateBy=SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE;
  boolean isEndOfSentence=(primaryCode == KeyCodes.ENTER || mSentenceSeparators.get(primaryCode));
  if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
    postUpdateSuggestions();
  }
  InputConnection ic=getCurrentInputConnection();
  if (ic != null) {
    ic.beginBatchEdit();
  }
  final boolean separatorInsideWord=(mWord.cursorPosition() < mWord.length());
  if (mPredicting && !separatorInsideWord) {
    if (primaryCode != '\'') {
      pickDefaultSuggestion(mAutoCorrectOn && primaryCode != KeyCodes.ENTER);
      if (primaryCode == KeyCodes.SPACE) {
        mJustAddedAutoSpace=true;
      }
    }
 else {
      commitTyped(ic);
      if (isEndOfSentence)       abortCorrection(true,false);
    }
  }
 else   if (separatorInsideWord) {
    abortCorrection(true,false);
  }
  if (mJustAddedAutoSpace && primaryCode == KeyCodes.ENTER) {
    removeTrailingSpace();
    mJustAddedAutoSpace=false;
  }
  if (primaryCode == KeyCodes.ENTER && mShiftKeyState.isPressed() && ic != null) {
    ic.commitText("String_Node_Str",1);
  }
 else {
    boolean handledOutputToInputConnection=false;
    if (ic != null) {
      if (primaryCode == KeyCodes.SPACE) {
        if (mAskPrefs.isDoubleSpaceChangesToPeriod()) {
          if ((SystemClock.uptimeMillis() - mLastSpaceTimeStamp) < ((long)mAskPrefs.getMultiTapTimeout())) {
            ic.deleteSurroundingText(1,0);
            ic.commitText("String_Node_Str",1);
            mJustAddedAutoSpace=true;
            isEndOfSentence=true;
            handledOutputToInputConnection=true;
          }
        }
      }
 else       if (mJustAddedAutoSpace && mLastSpaceTimeStamp != NEVER_TIME_STAMP && mAskPrefs.shouldSwapPunctuationAndSpace() && primaryCode != KeyCodes.ENTER && isSentenceSeparator(primaryCode)) {
        ic.deleteSurroundingText(1,0);
        ic.commitText(((char)primaryCode) + "String_Node_Str",1);
        mJustAddedAutoSpace=true;
        handledOutputToInputConnection=true;
      }
    }
    if (!handledOutputToInputConnection) {
      final EditorInfo ei=getCurrentInputEditorInfo();
      if (primaryCode == KeyCodes.ENTER && ic != null && ei != null && ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) > EditorInfo.IME_ACTION_NONE || ei.actionId > EditorInfo.IME_ACTION_NONE)) {
        final int actionId=ei.actionId > EditorInfo.IME_ACTION_NONE ? ei.actionId : ei.imeOptions & EditorInfo.IME_MASK_ACTION;
        ic.performEditorAction(actionId);
      }
 else {
        sendKeyChar((char)primaryCode);
      }
    }
    TextEntryState.typedCharacter((char)primaryCode,true);
  }
  if (ic != null) {
    ic.endBatchEdit();
  }
  if (isEndOfSentence) {
    mSuggest.resetNextWordSentence();
    clearSuggestions();
  }
 else   if (!TextUtils.isEmpty(mCommittedWord)) {
    setSuggestions(mSuggest.getNextSuggestions(mCommittedWord,mWord.isAllUpperCase()),false,false,false);
    mWord.setFirstCharCapitalized(false);
  }
}

Fixed version (ground truth):
private void handleSeparator(int primaryCode){
  if (!getCurrentAlphabetKeyboard().isLeftToRightLanguage()) {
    if (primaryCode == (int)')')     primaryCode=(int)'(';
 else     if (primaryCode == (int)'(')     primaryCode=(int)')';
  }
  mExpectingSelectionUpdateBy=SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE;
  boolean isEndOfSentence=(primaryCode == KeyCodes.ENTER || mSentenceSeparators.get(primaryCode));
  if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
    postUpdateSuggestions();
  }
  InputConnection ic=getCurrentInputConnection();
  if (ic != null) {
    ic.beginBatchEdit();
  }
  final boolean separatorInsideWord=(mWord.cursorPosition() < mWord.length());
  if (mPredicting && !separatorInsideWord) {
    if (primaryCode != '\'') {
      pickDefaultSuggestion(mAutoCorrectOn && primaryCode != KeyCodes.ENTER);
      if (primaryCode == KeyCodes.SPACE) {
        mJustAddedAutoSpace=true;
      }
    }
 else {
      commitTyped(ic);
      if (isEndOfSentence)       abortCorrection(true,false);
    }
  }
 else   if (separatorInsideWord) {
    abortCorrection(true,false);
  }
  if (mJustAddedAutoSpace && primaryCode == KeyCodes.ENTER) {
    removeTrailingSpace();
    mJustAddedAutoSpace=false;
  }
  boolean handledOutputToInputConnection=false;
  if (ic != null) {
    if (primaryCode == KeyCodes.SPACE) {
      if (mAskPrefs.isDoubleSpaceChangesToPeriod()) {
        if ((SystemClock.uptimeMillis() - mLastSpaceTimeStamp) < ((long)mAskPrefs.getMultiTapTimeout())) {
          ic.deleteSurroundingText(1,0);
          ic.commitText("String_Node_Str",1);
          mJustAddedAutoSpace=true;
          isEndOfSentence=true;
          handledOutputToInputConnection=true;
        }
      }
    }
 else     if (mJustAddedAutoSpace && mLastSpaceTimeStamp != NEVER_TIME_STAMP && mAskPrefs.shouldSwapPunctuationAndSpace() && primaryCode != KeyCodes.ENTER && isSentenceSeparator(primaryCode)) {
      ic.deleteSurroundingText(1,0);
      ic.commitText(((char)primaryCode) + "String_Node_Str",1);
      mJustAddedAutoSpace=true;
      handledOutputToInputConnection=true;
    }
  }
  if (!handledOutputToInputConnection) {
    sendKeyChar((char)primaryCode);
  }
  TextEntryState.typedCharacter((char)primaryCode,true);
  if (ic != null) {
    ic.endBatchEdit();
  }
  if (isEndOfSentence) {
    mSuggest.resetNextWordSentence();
    clearSuggestions();
  }
 else   if (!TextUtils.isEmpty(mCommittedWord)) {
    setSuggestions(mSuggest.getNextSuggestions(mCommittedWord,mWord.isAllUpperCase()),false,false,false);
    mWord.setFirstCharCapitalized(false);
  }
}