Program: 87353
Project: 87353
Buggy source:
/** 
 * Consider an update to the cursor position. Evaluate whether this update has happened as part of normal typing or whether it was an explicit cursor move by the user. In any case, do the necessary adjustments.
 * @param oldSelStart old selection start
 * @param oldSelEnd old selection end
 * @param newSelStart new selection start
 * @param newSelEnd new selection end
 * @return whether the cursor has moved as a result of user interaction.
 */
public boolean onUpdateSelection(final int oldSelStart,final int oldSelEnd,final int newSelStart,final int newSelEnd){
  if (mConnection.isBelatedExpectedUpdate(oldSelStart,newSelStart,oldSelEnd,newSelEnd)) {
    return false;
  }
  mSpaceState=SpaceState.NONE;
  final boolean selectionChangedOrSafeToReset=oldSelStart != newSelStart || oldSelEnd != newSelEnd || !mWordComposer.isComposingWord();
  final boolean hasOrHadSelection=(oldSelStart != oldSelEnd || newSelStart != newSelEnd);
  final int moveAmount=newSelStart - oldSelStart;
  if (hasOrHadSelection || (selectionChangedOrSafeToReset && !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
    resetEntireInputState(newSelStart,newSelEnd,false);
  }
 else {
    mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,false);
  }
  mRecapitalizeStatus.enable();
  mTextDecorator.reset();
  mConnection.removeBackgroundColorFromHighlightedTextIfNecessary();
  mLatinIME.mHandler.postResumeSuggestions(false,true);
  mRecapitalizeStatus.stop();
  return true;
}

Fixed version (ground truth):
/** 
 * Consider an update to the cursor position. Evaluate whether this update has happened as part of normal typing or whether it was an explicit cursor move by the user. In any case, do the necessary adjustments.
 * @param oldSelStart old selection start
 * @param oldSelEnd old selection end
 * @param newSelStart new selection start
 * @param newSelEnd new selection end
 * @param settingsValues the current values of the settings.
 * @return whether the cursor has moved as a result of user interaction.
 */
public boolean onUpdateSelection(final int oldSelStart,final int oldSelEnd,final int newSelStart,final int newSelEnd,final SettingsValues settingsValues){
  if (mConnection.isBelatedExpectedUpdate(oldSelStart,newSelStart,oldSelEnd,newSelEnd)) {
    return false;
  }
  mSpaceState=SpaceState.NONE;
  final boolean selectionChangedOrSafeToReset=oldSelStart != newSelStart || oldSelEnd != newSelEnd || !mWordComposer.isComposingWord();
  final boolean hasOrHadSelection=(oldSelStart != oldSelEnd || newSelStart != newSelEnd);
  final int moveAmount=newSelStart - oldSelStart;
  if (hasOrHadSelection || !settingsValues.needsToLookupSuggestions() || (selectionChangedOrSafeToReset && !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
    resetEntireInputState(newSelStart,newSelEnd,false);
  }
 else {
    mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,false);
  }
  mRecapitalizeStatus.enable();
  mTextDecorator.reset();
  mConnection.removeBackgroundColorFromHighlightedTextIfNecessary();
  mLatinIME.mHandler.postResumeSuggestions(false,true);
  mRecapitalizeStatus.stop();
  return true;
}