Program: 157341
Project: 157341
Buggy source:
private void handleSeparator(int primaryCode){
  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;
  }
  final EditorInfo ei=getCurrentInputEditorInfo();
  if (primaryCode == KeyCodes.ENTER && mShiftKeyState.isActive() && ic != null && ei != null && (ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE) {
    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)     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;
  }
  final EditorInfo ei=getCurrentInputEditorInfo();
  if (primaryCode == KeyCodes.ENTER && mShiftKeyState.isActive() && ic != null && ei != null && (ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE) {
    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)     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);
  }
}