Program: 87380
Project: 87380
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 shouldIncludeResumedWordInSuggestions whether to include the word on which we resumesuggestions in the suggestion list.
 */
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,final boolean shouldIncludeResumedWordInSuggestions,final int currentKeyboardScriptId){
  if (settingsValues.isBrokenByRecorrection() || !settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces || !settingsValues.needsToLookupSuggestions()|| mInputLogicHandler.isInBatchInput()|| mConnection.hasSelection()|| mConnection.getExpectedSelectionStart() < 0) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
    return;
  }
  final int expectedCursorPosition=mConnection.getExpectedSelectionStart();
  if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations)) {
    mWordComposer.setCapitalizedModeAtStartComposingTime(WordComposer.CAPS_MODE_OFF);
    mLatinIME.mHandler.postUpdateSuggestionStrip();
    return;
  }
  final TextRange range=mConnection.getWordRangeAtCursor(settingsValues.mSpacingAndPunctuations.mSortedWordSeparators,currentKeyboardScriptId);
  if (null == range)   return;
  if (range.length() <= 0) {
    mLatinIME.setNeutralSuggestionStrip();
    return;
  }
  if (range.mHasUrlSpans)   return;
  final int numberOfCharsInWordBeforeCursor=range.getNumberOfCharsInWordBeforeCursor();
  if (numberOfCharsInWordBeforeCursor > expectedCursorPosition)   return;
  final ArrayList<SuggestedWordInfo> suggestions=new ArrayList<>();
  final String typedWord=range.mWord.toString();
  if (shouldIncludeResumedWordInSuggestions) {
    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)) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
    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);
  final PrevWordsInfo prevWordsInfo=getPrevWordsInfoFromNthPreviousWordForSuggestion(settingsValues.mSpacingAndPunctuations,0 == numberOfCharsInWordBeforeCursor ? 1 : 2);
  mWordComposer.setComposingWord(codePoints,mLatinIME.getCoordinatesForCurrentKeyboard(codePoints));
  mWordComposer.setCursorPositionWithinWord(typedWord.codePointCount(0,numberOfCharsInWordBeforeCursor));
  mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor,expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor());
  if (suggestions.size() <= (shouldIncludeResumedWordInSuggestions ? 1 : 0)) {
    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 && !shouldIncludeResumedWordInSuggestions) {
          suggestedWords=suggestedWordsIncludingTypedWord.getSuggestedWordsExcludingTypedWord();
        }
 else {
          suggestedWords=suggestedWordsIncludingTypedWord;
        }
        mIsAutoCorrectionIndicatorOn=false;
        mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
      }
    }
);
  }
 else {
    final SuggestedWords suggestedWords=new SuggestedWords(suggestions,null,typedWord,false,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 shouldIncludeResumedWordInSuggestions whether to include the word on which we resumesuggestions in the suggestion list.
 */
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,final boolean shouldIncludeResumedWordInSuggestions,final int currentKeyboardScriptId){
  if (settingsValues.isBrokenByRecorrection() || !settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces || !settingsValues.needsToLookupSuggestions()|| mInputLogicHandler.isInBatchInput()|| mConnection.hasSelection()|| mConnection.getExpectedSelectionStart() < 0) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
    return;
  }
  final int expectedCursorPosition=mConnection.getExpectedSelectionStart();
  if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations)) {
    mWordComposer.setCapitalizedModeAtStartComposingTime(WordComposer.CAPS_MODE_OFF);
    mLatinIME.mHandler.postUpdateSuggestionStrip();
    return;
  }
  final TextRange range=mConnection.getWordRangeAtCursor(settingsValues.mSpacingAndPunctuations.mSortedWordSeparators,currentKeyboardScriptId);
  if (null == range)   return;
  if (range.length() <= 0) {
    mLatinIME.setNeutralSuggestionStrip();
    return;
  }
  if (range.mHasUrlSpans)   return;
  final int numberOfCharsInWordBeforeCursor=range.getNumberOfCharsInWordBeforeCursor();
  if (numberOfCharsInWordBeforeCursor > expectedCursorPosition)   return;
  final ArrayList<SuggestedWordInfo> suggestions=new ArrayList<>();
  final String typedWord=range.mWord.toString();
  if (shouldIncludeResumedWordInSuggestions) {
    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)) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
    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);
  final PrevWordsInfo prevWordsInfo=getPrevWordsInfoFromNthPreviousWordForSuggestion(settingsValues.mSpacingAndPunctuations,0 == numberOfCharsInWordBeforeCursor ? 1 : 2);
  mWordComposer.setComposingWord(codePoints,mLatinIME.getCoordinatesForCurrentKeyboard(codePoints));
  mWordComposer.setCursorPositionWithinWord(typedWord.codePointCount(0,numberOfCharsInWordBeforeCursor));
  mConnection.maybeMoveTheCursorAroundAndRestoreToWorkaroundABug();
  mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor,expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor());
  if (suggestions.size() <= (shouldIncludeResumedWordInSuggestions ? 1 : 0)) {
    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 && !shouldIncludeResumedWordInSuggestions) {
          suggestedWords=suggestedWordsIncludingTypedWord.getSuggestedWordsExcludingTypedWord();
        }
 else {
          suggestedWords=suggestedWordsIncludingTypedWord;
        }
        mIsAutoCorrectionIndicatorOn=false;
        mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
      }
    }
);
  }
 else {
    final SuggestedWords suggestedWords=new SuggestedWords(suggestions,null,typedWord,false,false,false,false,SuggestedWords.NOT_A_SEQUENCE_NUMBER);
    mIsAutoCorrectionIndicatorOn=false;
    mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
  }
}