Program: 87438
Project: 87438
Buggy source:
/** 
 * Check if the cursor is touching a word. If so, restart suggestions on this word, else do nothing.
 * @param settingsValues the current values of the settings.
 * @param includeResumedWordInSuggestions whether to include the word on which we resumesuggestions in the suggestion list.
 */
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,final boolean includeResumedWordInSuggestions){
  if (settingsValues.isBrokenByRecorrection())   return;
  if (!settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces)   return;
  if (!settingsValues.isSuggestionsRequested())   return;
  if (mConnection.hasSelection())   return;
  if (mConnection.getExpectedSelectionStart() < 0)   return;
  final int expectedCursorPosition=mConnection.getExpectedSelectionStart();
  if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations))   return;
  final TextRange range=mConnection.getWordRangeAtCursor(settingsValues.mSpacingAndPunctuations.mSortedWordSeparators,0);
  if (null == range)   return;
  if (range.length() <= 0)   return;
  if (range.mHasUrlSpans)   return;
  final int numberOfCharsInWordBeforeCursor=range.getNumberOfCharsInWordBeforeCursor();
  if (numberOfCharsInWordBeforeCursor > expectedCursorPosition)   return;
  final ArrayList<SuggestedWordInfo> suggestions=CollectionUtils.newArrayList();
  final String typedWord=range.mWord.toString();
  if (includeResumedWordInSuggestions) {
    suggestions.add(new SuggestedWordInfo(typedWord,SuggestedWords.MAX_SUGGESTIONS + 1,SuggestedWordInfo.KIND_TYPED,Dictionary.DICTIONARY_USER_TYPED,SuggestedWordInfo.NOT_AN_INDEX,SuggestedWordInfo.NOT_A_CONFIDENCE));
  }
  if (!isResumableWord(settingsValues,typedWord))   return;
  int i=0;
  for (  final SuggestionSpan span : range.getSuggestionSpansAtWord()) {
    for (    final String s : span.getSuggestions()) {
      ++i;
      if (!TextUtils.equals(s,typedWord)) {
        suggestions.add(new SuggestedWordInfo(s,SuggestedWords.MAX_SUGGESTIONS - i,SuggestedWordInfo.KIND_RESUMED,Dictionary.DICTIONARY_RESUMED,SuggestedWordInfo.NOT_AN_INDEX,SuggestedWordInfo.NOT_A_CONFIDENCE));
      }
    }
  }
  final int[] codePoints=StringUtils.toCodePointArray(typedWord);
  mWordComposer.setComposingWord(codePoints,mLatinIME.getCoordinatesForCurrentKeyboard(codePoints),getNthPreviousWordForSuggestion(settingsValues.mSpacingAndPunctuations,0 == numberOfCharsInWordBeforeCursor ? 1 : 2));
  mWordComposer.setCursorPositionWithinWord(typedWord.codePointCount(0,numberOfCharsInWordBeforeCursor));
  mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor,expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor());
  if (suggestions.isEmpty()) {
    mInputLogicHandler.getSuggestedWords(Suggest.SESSION_TYPING,SuggestedWords.NOT_A_SEQUENCE_NUMBER,new OnGetSuggestedWordsCallback(){
      @Override public void onGetSuggestedWords(      final SuggestedWords suggestedWordsIncludingTypedWord){
        final SuggestedWords suggestedWords;
        if (suggestedWordsIncludingTypedWord.size() > 1 && !includeResumedWordInSuggestions) {
          suggestedWords=suggestedWordsIncludingTypedWord.getSuggestedWordsExcludingTypedWord();
        }
 else {
          suggestedWords=suggestedWordsIncludingTypedWord;
        }
        mIsAutoCorrectionIndicatorOn=false;
        mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
      }
    }
);
  }
 else {
    final SuggestedWords suggestedWords=new SuggestedWords(suggestions,null,typedWord,true,false,false,false,SuggestedWords.NOT_A_SEQUENCE_NUMBER);
    mIsAutoCorrectionIndicatorOn=false;
    mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
  }
}

Fixed version (ground truth):
/** 
 * Check if the cursor is touching a word. If so, restart suggestions on this word, else do nothing.
 * @param settingsValues the current values of the settings.
 * @param includeResumedWordInSuggestions whether to include the word on which we resumesuggestions in the suggestion list.
 */
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,final boolean includeResumedWordInSuggestions){
  if (settingsValues.isBrokenByRecorrection() || !settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces || !settingsValues.isSuggestionsRequested()|| mConnection.hasSelection()|| mConnection.getExpectedSelectionStart() < 0) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
    return;
  }
  final int expectedCursorPosition=mConnection.getExpectedSelectionStart();
  if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations)) {
    mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(WordComposer.CAPS_MODE_OFF,getNthPreviousWordForSuggestion(settingsValues.mSpacingAndPunctuations,1));
    mLatinIME.mHandler.postUpdateSuggestionStrip();
    return;
  }
  final TextRange range=mConnection.getWordRangeAtCursor(settingsValues.mSpacingAndPunctuations.mSortedWordSeparators,0);
  if (null == range)   return;
  if (range.length() <= 0)   return;
  if (range.mHasUrlSpans)   return;
  final int numberOfCharsInWordBeforeCursor=range.getNumberOfCharsInWordBeforeCursor();
  if (numberOfCharsInWordBeforeCursor > expectedCursorPosition)   return;
  final ArrayList<SuggestedWordInfo> suggestions=CollectionUtils.newArrayList();
  final String typedWord=range.mWord.toString();
  if (includeResumedWordInSuggestions) {
    suggestions.add(new SuggestedWordInfo(typedWord,SuggestedWords.MAX_SUGGESTIONS + 1,SuggestedWordInfo.KIND_TYPED,Dictionary.DICTIONARY_USER_TYPED,SuggestedWordInfo.NOT_AN_INDEX,SuggestedWordInfo.NOT_A_CONFIDENCE));
  }
  if (!isResumableWord(settingsValues,typedWord))   return;
  int i=0;
  for (  final SuggestionSpan span : range.getSuggestionSpansAtWord()) {
    for (    final String s : span.getSuggestions()) {
      ++i;
      if (!TextUtils.equals(s,typedWord)) {
        suggestions.add(new SuggestedWordInfo(s,SuggestedWords.MAX_SUGGESTIONS - i,SuggestedWordInfo.KIND_RESUMED,Dictionary.DICTIONARY_RESUMED,SuggestedWordInfo.NOT_AN_INDEX,SuggestedWordInfo.NOT_A_CONFIDENCE));
      }
    }
  }
  final int[] codePoints=StringUtils.toCodePointArray(typedWord);
  mWordComposer.setComposingWord(codePoints,mLatinIME.getCoordinatesForCurrentKeyboard(codePoints),getNthPreviousWordForSuggestion(settingsValues.mSpacingAndPunctuations,0 == numberOfCharsInWordBeforeCursor ? 1 : 2));
  mWordComposer.setCursorPositionWithinWord(typedWord.codePointCount(0,numberOfCharsInWordBeforeCursor));
  mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor,expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor());
  if (suggestions.isEmpty()) {
    mInputLogicHandler.getSuggestedWords(Suggest.SESSION_TYPING,SuggestedWords.NOT_A_SEQUENCE_NUMBER,new OnGetSuggestedWordsCallback(){
      @Override public void onGetSuggestedWords(      final SuggestedWords suggestedWordsIncludingTypedWord){
        final SuggestedWords suggestedWords;
        if (suggestedWordsIncludingTypedWord.size() > 1 && !includeResumedWordInSuggestions) {
          suggestedWords=suggestedWordsIncludingTypedWord.getSuggestedWordsExcludingTypedWord();
        }
 else {
          suggestedWords=suggestedWordsIncludingTypedWord;
        }
        mIsAutoCorrectionIndicatorOn=false;
        mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
      }
    }
);
  }
 else {
    final SuggestedWords suggestedWords=new SuggestedWords(suggestions,null,typedWord,true,false,false,false,SuggestedWords.NOT_A_SEQUENCE_NUMBER);
    mIsAutoCorrectionIndicatorOn=false;
    mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
  }
}