nus-yam/ex-repair huggingface dataset:
Program: 87374
Project: 87374
Buggy source:
@Override public void onGetSuggestedWords(final SuggestedWords suggestedWordsIncludingTypedWord){
  final SuggestedWords suggestedWords;
  if (suggestedWordsIncludingTypedWord.size() > 1 && !shouldIncludeResumedWordInSuggestions) {
    suggestedWords=suggestedWordsIncludingTypedWord.getSuggestedWordsExcludingTypedWord(SuggestedWords.INPUT_STYLE_RECORRECTION);
  }
 else {
    suggestedWords=suggestedWordsIncludingTypedWord;
  }
  mIsAutoCorrectionIndicatorOn=false;
  mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
}

Fixed version (ground truth):
@Override public void onGetSuggestedWords(final SuggestedWords suggestedWordsIncludingTypedWord){
  final SuggestedWords suggestedWords;
  if (suggestedWordsIncludingTypedWord.size() > 1 && !shouldIncludeResumedWordInSuggestions) {
    suggestedWords=suggestedWordsIncludingTypedWord.getSuggestedWordsExcludingTypedWordForRecorrection();
  }
 else {
    suggestedWords=suggestedWordsIncludingTypedWord;
  }
  mIsAutoCorrectionIndicatorOn=false;
  mLatinIME.mHandler.showSuggestionStrip(suggestedWords);
}
Program: 87375
Project: 87375
Buggy source:
/** 
 * Make a   {@link com.android.inputmethod.latin.SuggestedWords} object containing a typed wordand obsolete suggestions. See  {@link com.android.inputmethod.latin.SuggestedWords#getTypedWordAndPreviousSuggestions(String,com.android.inputmethod.latin.SuggestedWords)}.
 * @param typedWord The typed word as a string.
 * @param previousSuggestedWords The previously suggested words.
 * @return Obsolete suggestions with the newly typed word.
 */
private SuggestedWords retrieveOlderSuggestions(final String typedWord,final SuggestedWords previousSuggestedWords){
  final SuggestedWords oldSuggestedWords=previousSuggestedWords.isPunctuationSuggestions() ? SuggestedWords.EMPTY : previousSuggestedWords;
  final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions=SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord,oldSuggestedWords);
  return new SuggestedWords(typedWordAndPreviousSuggestions,null,false,false,true,false,oldSuggestedWords.mInputStyle);
}

Fixed version (ground truth):
/** 
 * Make a   {@link com.android.inputmethod.latin.SuggestedWords} object containing a typed wordand obsolete suggestions. See  {@link com.android.inputmethod.latin.SuggestedWords#getTypedWordAndPreviousSuggestions(String,com.android.inputmethod.latin.SuggestedWords)}.
 * @param typedWord The typed word as a string.
 * @param previousSuggestedWords The previously suggested words.
 * @return Obsolete suggestions with the newly typed word.
 */
private SuggestedWords retrieveOlderSuggestions(final String typedWord,final SuggestedWords previousSuggestedWords){
  final SuggestedWords oldSuggestedWords=previousSuggestedWords.isPunctuationSuggestions() ? SuggestedWords.EMPTY : previousSuggestedWords;
  final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions=SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord,oldSuggestedWords);
  return new SuggestedWords(typedWordAndPreviousSuggestions,null,false,false,true,oldSuggestedWords.mInputStyle);
}
Program: 87377
Project: 87377
Buggy source:
public void testGetTypedWordInfoOrNull(){
  final String TYPED_WORD="String_Node_Str";
  final int NUMBER_OF_ADDED_SUGGESTIONS=5;
  final ArrayList<SuggestedWordInfo> list=new ArrayList<>();
  list.add(createTypedWordInfo(TYPED_WORD));
  for (int i=0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
    list.add(createCorrectionWordInfo(Integer.toString(i)));
  }
  final SuggestedWords wordsWithTypedWord=new SuggestedWords(list,null,false,false,false,false,SuggestedWords.INPUT_STYLE_NONE);
  final SuggestedWordInfo typedWord=wordsWithTypedWord.getTypedWordInfoOrNull();
  assertNotNull(typedWord);
  assertEquals(TYPED_WORD,typedWord.mWord);
  final SuggestedWords wordsWithoutTypedWord=wordsWithTypedWord.getSuggestedWordsExcludingTypedWord(SuggestedWords.INPUT_STYLE_NONE);
  assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
  assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
}

Fixed version (ground truth):
public void testGetTypedWordInfoOrNull(){
  final String TYPED_WORD="String_Node_Str";
  final int NUMBER_OF_ADDED_SUGGESTIONS=5;
  final ArrayList<SuggestedWordInfo> list=new ArrayList<>();
  list.add(createTypedWordInfo(TYPED_WORD));
  for (int i=0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
    list.add(createCorrectionWordInfo(Integer.toString(i)));
  }
  final SuggestedWords wordsWithTypedWord=new SuggestedWords(list,null,false,false,false,SuggestedWords.INPUT_STYLE_NONE);
  final SuggestedWordInfo typedWord=wordsWithTypedWord.getTypedWordInfoOrNull();
  assertNotNull(typedWord);
  assertEquals(TYPED_WORD,typedWord.mWord);
  final SuggestedWords wordsWithoutTypedWord=wordsWithTypedWord.getSuggestedWordsExcludingTypedWordForRecorrection();
  assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
  assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
}
Program: 87378
Project: 87378
Buggy source:
public void testGetSuggestedWordsExcludingTypedWord(){
  final String TYPED_WORD="String_Node_Str";
  final int NUMBER_OF_ADDED_SUGGESTIONS=5;
  final ArrayList<SuggestedWordInfo> list=new ArrayList<>();
  list.add(createTypedWordInfo(TYPED_WORD));
  for (int i=0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
    list.add(createCorrectionWordInfo(Integer.toString(i)));
  }
  final SuggestedWords words=new SuggestedWords(list,null,false,false,false,false,SuggestedWords.INPUT_STYLE_NONE);
  assertEquals(NUMBER_OF_ADDED_SUGGESTIONS + 1,words.size());
  assertEquals("String_Node_Str",words.getWord(0));
  assertTrue(words.getInfo(0).isKindOf(SuggestedWordInfo.KIND_TYPED));
  assertEquals("String_Node_Str",words.getWord(1));
  assertTrue(words.getInfo(1).isKindOf(SuggestedWordInfo.KIND_CORRECTION));
  assertEquals("String_Node_Str",words.getWord(5));
  assertTrue(words.getInfo(5).isKindOf(SuggestedWordInfo.KIND_CORRECTION));
  final SuggestedWords wordsWithoutTyped=words.getSuggestedWordsExcludingTypedWord(SuggestedWords.INPUT_STYLE_NONE);
  assertEquals(words.size() - 1,wordsWithoutTyped.size());
  assertEquals("String_Node_Str",wordsWithoutTyped.getWord(0));
  assertTrue(wordsWithoutTyped.getInfo(0).isKindOf(SuggestedWordInfo.KIND_CORRECTION));
}

Fixed version (ground truth):
public void testGetSuggestedWordsExcludingTypedWord(){
  final String TYPED_WORD="String_Node_Str";
  final int NUMBER_OF_ADDED_SUGGESTIONS=5;
  final int KIND_OF_SECOND_CORRECTION=SuggestedWordInfo.KIND_CORRECTION;
  final ArrayList<SuggestedWordInfo> list=new ArrayList<>();
  list.add(createTypedWordInfo(TYPED_WORD));
  for (int i=0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
    list.add(createCorrectionWordInfo(Integer.toString(i)));
  }
  final SuggestedWords words=new SuggestedWords(list,null,false,false,false,SuggestedWords.INPUT_STYLE_NONE);
  assertEquals(NUMBER_OF_ADDED_SUGGESTIONS + 1,words.size());
  assertEquals("String_Node_Str",words.getWord(0));
  assertTrue(words.getInfo(0).isKindOf(SuggestedWordInfo.KIND_TYPED));
  assertEquals("String_Node_Str",words.getWord(1));
  assertTrue(words.getInfo(1).isKindOf(KIND_OF_SECOND_CORRECTION));
  assertEquals("String_Node_Str",words.getWord(5));
  assertTrue(words.getInfo(5).isKindOf(KIND_OF_SECOND_CORRECTION));
  final SuggestedWords wordsWithoutTyped=words.getSuggestedWordsExcludingTypedWordForRecorrection();
  assertEquals(words.size() - 1,wordsWithoutTyped.size());
  assertEquals("String_Node_Str",wordsWithoutTyped.getWord(0));
  assertTrue(wordsWithoutTyped.getInfo(0).isKindOf(KIND_OF_SECOND_CORRECTION));
}
Program: 87379
Project: 87379
Buggy source:
private static void testingStandardPunctuationSuggestions(final SpacingAndPunctuations sp,final String[] punctuationLabels,final String[] punctuationWords){
  final SuggestedWords suggestedWords=sp.mSuggestPuncList;
  assertFalse("String_Node_Str",suggestedWords.mTypedWordValid);
  assertFalse("String_Node_Str",suggestedWords.mWillAutoCorrect);
  assertTrue("String_Node_Str",suggestedWords.isPunctuationSuggestions());
  assertFalse("String_Node_Str",suggestedWords.mIsObsoleteSuggestions);
  assertFalse("String_Node_Str",suggestedWords.mIsPrediction);
  assertEquals("String_Node_Str",punctuationLabels.length,suggestedWords.size());
  for (int index=0; index < suggestedWords.size(); index++) {
    assertEquals("String_Node_Str" + index,punctuationLabels[index],suggestedWords.getLabel(index));
    assertEquals("String_Node_Str" + index,punctuationWords[index],suggestedWords.getWord(index));
  }
}

Fixed version (ground truth):
private static void testingStandardPunctuationSuggestions(final SpacingAndPunctuations sp,final String[] punctuationLabels,final String[] punctuationWords){
  final SuggestedWords suggestedWords=sp.mSuggestPuncList;
  assertFalse("String_Node_Str",suggestedWords.mTypedWordValid);
  assertFalse("String_Node_Str",suggestedWords.mWillAutoCorrect);
  assertTrue("String_Node_Str",suggestedWords.isPunctuationSuggestions());
  assertFalse("String_Node_Str",suggestedWords.mIsObsoleteSuggestions);
  assertFalse("String_Node_Str",suggestedWords.isPrediction());
  assertEquals("String_Node_Str",punctuationLabels.length,suggestedWords.size());
  for (int index=0; index < suggestedWords.size(); index++) {
    assertEquals("String_Node_Str" + index,punctuationLabels[index],suggestedWords.getLabel(index));
    assertEquals("String_Node_Str" + index,punctuationWords[index],suggestedWords.getWord(index));
  }
}
Program: 87383
Project: 87383
Buggy source:
@Override public Event decodeHardwareKey(final KeyEvent keyEvent){
  final int codePointAndFlags=keyEvent.getUnicodeChar();
  final int keyCode=keyEvent.getKeyCode();
  final boolean isKeyRepeat=(0 != keyEvent.getRepeatCount());
  if (KeyEvent.KEYCODE_DEL == keyCode) {
    return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_DELETE,null,isKeyRepeat);
  }
  if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) {
    if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
      return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK,keyCode,null);
    }
    if (KeyEvent.KEYCODE_ENTER == keyCode) {
      if (keyEvent.isShiftPressed()) {
        return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_SHIFT_ENTER,null,isKeyRepeat);
      }
 else {
        return Event.createHardwareKeypressEvent(Constants.CODE_ENTER,keyCode,null,isKeyRepeat);
      }
    }
    return Event.createHardwareKeypressEvent(keyCode,codePointAndFlags,null,isKeyRepeat);
  }
  return Event.createNotHandledEvent();
}

Fixed version (ground truth):
@Override public Event decodeHardwareKey(final KeyEvent keyEvent){
  final int codePointAndFlags=keyEvent.getUnicodeChar();
  final int keyCode=keyEvent.getKeyCode();
  final boolean isKeyRepeat=(0 != keyEvent.getRepeatCount());
  if (KeyEvent.KEYCODE_DEL == keyCode) {
    return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_DELETE,null,isKeyRepeat);
  }
  if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) {
    if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
      return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK,keyCode,null);
    }
    if (KeyEvent.KEYCODE_ENTER == keyCode) {
      if (keyEvent.isShiftPressed()) {
        return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_SHIFT_ENTER,null,isKeyRepeat);
      }
 else {
        return Event.createHardwareKeypressEvent(Constants.CODE_ENTER,keyCode,null,isKeyRepeat);
      }
    }
    return Event.createHardwareKeypressEvent(codePointAndFlags,keyCode,null,isKeyRepeat);
  }
  return Event.createNotHandledEvent();
}
Program: 87385
Project: 87385
Buggy source:
@Override public Event decodeHardwareKey(final KeyEvent keyEvent){
  final int codePointAndFlags=keyEvent.getUnicodeChar();
  final int keyCode=keyEvent.getKeyCode();
  final boolean isKeyRepeat=(0 != keyEvent.getRepeatCount());
  if (KeyEvent.KEYCODE_DEL == keyCode) {
    return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_DELETE,null,isKeyRepeat);
  }
  if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) {
    if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
      return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK,keyCode,null);
    }
    if (KeyEvent.KEYCODE_ENTER == keyCode) {
      if (keyEvent.isShiftPressed()) {
        return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_SHIFT_ENTER,null,isKeyRepeat);
      }
 else {
        return Event.createHardwareKeypressEvent(Constants.CODE_ENTER,keyCode,null,isKeyRepeat);
      }
    }
    return Event.createHardwareKeypressEvent(keyCode,codePointAndFlags,null,isKeyRepeat);
  }
  return Event.createNotHandledEvent();
}

Fixed version (ground truth):
@Override public Event decodeHardwareKey(final KeyEvent keyEvent){
  final int codePointAndFlags=keyEvent.getUnicodeChar();
  final int keyCode=keyEvent.getKeyCode();
  final boolean isKeyRepeat=(0 != keyEvent.getRepeatCount());
  if (KeyEvent.KEYCODE_DEL == keyCode) {
    return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_DELETE,null,isKeyRepeat);
  }
  if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) {
    if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
      return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK,keyCode,null);
    }
    if (KeyEvent.KEYCODE_ENTER == keyCode) {
      if (keyEvent.isShiftPressed()) {
        return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,Constants.CODE_SHIFT_ENTER,null,isKeyRepeat);
      }
 else {
        return Event.createHardwareKeypressEvent(Constants.CODE_ENTER,keyCode,null,isKeyRepeat);
      }
    }
    return Event.createHardwareKeypressEvent(codePointAndFlags,keyCode,null,isKeyRepeat);
  }
  return Event.createNotHandledEvent();
}
Program: 87387
Project: 87387
Buggy source:
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    mInputLogic.finishInput();
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    if (mInputLogic.mWordComposer.isComposingWord()) {
      mInputLogic.mConnection.beginBatchEdit();
      mInputLogic.commitTyped(mSettings.getCurrent(),LastComposedWord.NOT_A_SEPARATOR);
      mInputLogic.mConnection.endBatchEdit();
    }
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}
Program: 87388
Project: 87388
Buggy source:
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    mInputLogic.mConnection.beginBatchEdit();
    mInputLogic.commitTyped(mSettings.getCurrent(),LastComposedWord.NOT_A_SEPARATOR);
    mInputLogic.mConnection.finishComposingText();
    mInputLogic.mConnection.endBatchEdit();
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    mInputLogic.finishInput();
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}
Program: 87389
Project: 87389
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 (selectionChangedOrSafeToReset && (hasOrHadSelection || !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
    resetEntireInputState(newSelStart,newSelEnd,false);
  }
 else {
    mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,false);
  }
  mRecapitalizeStatus.enable();
  mLatinIME.mHandler.postResumeSuggestions();
  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
 * @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();
  mLatinIME.mHandler.postResumeSuggestions();
  mRecapitalizeStatus.stop();
  return true;
}
Program: 87390
Project: 87390
Buggy source:
/** 
 * Retry resetting caches in the rich input connection. When the editor can't be accessed we can't reset the caches, so we schedule a retry. This method handles the retry, and re-schedules a new retry if we still can't access. We only retry up to 5 times before giving up.
 * @param settingsValues the current values of the settings.
 * @param tryResumeSuggestions Whether we should resume suggestions or not.
 * @param remainingTries How many times we may try again before giving up.
 * @return whether true if the caches were successfully reset, false otherwise.
 */
public boolean retryResetCachesAndReturnSuccess(final SettingsValues settingsValues,final boolean tryResumeSuggestions,final int remainingTries,final LatinIME.UIHandler handler){
  if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mConnection.getExpectedSelectionStart(),mConnection.getExpectedSelectionEnd(),false)) {
    if (0 < remainingTries) {
      handler.postResetCaches(tryResumeSuggestions,remainingTries - 1);
      return false;
    }
  }
  mConnection.tryFixLyingCursorPosition();
  if (tryResumeSuggestions) {
    handler.postResumeSuggestions();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Retry resetting caches in the rich input connection. When the editor can't be accessed we can't reset the caches, so we schedule a retry. This method handles the retry, and re-schedules a new retry if we still can't access. We only retry up to 5 times before giving up.
 * @param settingsValues the current values of the settings.
 * @param tryResumeSuggestions Whether we should resume suggestions or not.
 * @param remainingTries How many times we may try again before giving up.
 * @return whether true if the caches were successfully reset, false otherwise.
 */
public boolean retryResetCachesAndReturnSuccess(final SettingsValues settingsValues,final boolean tryResumeSuggestions,final int remainingTries,final LatinIME.UIHandler handler){
  final boolean shouldFinishComposition=mConnection.hasSelection() || !mConnection.isCursorPositionKnown();
  if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mConnection.getExpectedSelectionStart(),mConnection.getExpectedSelectionEnd(),shouldFinishComposition)) {
    if (0 < remainingTries) {
      handler.postResetCaches(tryResumeSuggestions,remainingTries - 1);
      return false;
    }
  }
  mConnection.tryFixLyingCursorPosition();
  if (tryResumeSuggestions) {
    handler.postResumeSuggestions();
  }
  return true;
}
Program: 87391
Project: 87391
Buggy source:
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    mInputLogic.finishInput();
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    if (mInputLogic.mWordComposer.isComposingWord()) {
      mInputLogic.mConnection.beginBatchEdit();
      mInputLogic.commitTyped(mSettings.getCurrent(),LastComposedWord.NOT_A_SEPARATOR);
      mInputLogic.mConnection.endBatchEdit();
    }
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}
Program: 87392
Project: 87392
Buggy source:
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    mInputLogic.mConnection.beginBatchEdit();
    mInputLogic.commitTyped(mSettings.getCurrent(),LastComposedWord.NOT_A_SEPARATOR);
    mInputLogic.mConnection.finishComposingText();
    mInputLogic.mConnection.endBatchEdit();
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(final Configuration conf){
  final SettingsValues settingsValues=mSettings.getCurrent();
  if (settingsValues.mDisplayOrientation != conf.orientation) {
    mHandler.startOrientationChanging();
    mInputLogic.finishInput();
  }
  PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this,conf,mDictionaryFacilitator);
  super.onConfigurationChanged(conf);
}
Program: 87393
Project: 87393
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 (selectionChangedOrSafeToReset && (hasOrHadSelection || !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
    resetEntireInputState(newSelStart,newSelEnd,false);
  }
 else {
    mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,false);
  }
  mRecapitalizeStatus.enable();
  mLatinIME.mHandler.postResumeSuggestions();
  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
 * @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();
  mLatinIME.mHandler.postResumeSuggestions();
  mRecapitalizeStatus.stop();
  return true;
}
Program: 87394
Project: 87394
Buggy source:
/** 
 * Retry resetting caches in the rich input connection. When the editor can't be accessed we can't reset the caches, so we schedule a retry. This method handles the retry, and re-schedules a new retry if we still can't access. We only retry up to 5 times before giving up.
 * @param settingsValues the current values of the settings.
 * @param tryResumeSuggestions Whether we should resume suggestions or not.
 * @param remainingTries How many times we may try again before giving up.
 * @return whether true if the caches were successfully reset, false otherwise.
 */
public boolean retryResetCachesAndReturnSuccess(final SettingsValues settingsValues,final boolean tryResumeSuggestions,final int remainingTries,final LatinIME.UIHandler handler){
  if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mConnection.getExpectedSelectionStart(),mConnection.getExpectedSelectionEnd(),false)) {
    if (0 < remainingTries) {
      handler.postResetCaches(tryResumeSuggestions,remainingTries - 1);
      return false;
    }
  }
  mConnection.tryFixLyingCursorPosition();
  if (tryResumeSuggestions) {
    handler.postResumeSuggestions();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Retry resetting caches in the rich input connection. When the editor can't be accessed we can't reset the caches, so we schedule a retry. This method handles the retry, and re-schedules a new retry if we still can't access. We only retry up to 5 times before giving up.
 * @param settingsValues the current values of the settings.
 * @param tryResumeSuggestions Whether we should resume suggestions or not.
 * @param remainingTries How many times we may try again before giving up.
 * @return whether true if the caches were successfully reset, false otherwise.
 */
public boolean retryResetCachesAndReturnSuccess(final SettingsValues settingsValues,final boolean tryResumeSuggestions,final int remainingTries,final LatinIME.UIHandler handler){
  final boolean shouldFinishComposition=mConnection.hasSelection() || !mConnection.isCursorPositionKnown();
  if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mConnection.getExpectedSelectionStart(),mConnection.getExpectedSelectionEnd(),shouldFinishComposition)) {
    if (0 < remainingTries) {
      handler.postResetCaches(tryResumeSuggestions,remainingTries - 1);
      return false;
    }
  }
  mConnection.tryFixLyingCursorPosition();
  if (tryResumeSuggestions) {
    handler.postResumeSuggestions();
  }
  return true;
}
Program: 87395
Project: 87395
Buggy source:
private void onDownEvent(final int x,final int y,final long eventTime,final KeyDetector keyDetector){
  if (DEBUG_EVENT) {
    printTouchEvent("String_Node_Str",x,y,eventTime);
  }
  setKeyDetectorInner(keyDetector);
  final long deltaT=eventTime - mUpTime;
  if (deltaT < sParams.mTouchNoiseThresholdTime) {
    final int distance=getDistance(x,y,mLastX,mLastY);
    if (distance < sParams.mTouchNoiseThresholdDistance) {
      if (DEBUG_MODE)       Log.w(TAG,String.format("String_Node_Str" + "String_Node_Str",mPointerId,deltaT,distance));
      cancelTrackingForAction();
      return;
    }
  }
  final Key key=getKeyOn(x,y);
  mBogusMoveEventDetector.onActualDownEvent(x,y);
  if (key != null && key.isModifier()) {
    sPointerTrackerQueue.releaseAllPointers(eventTime);
  }
  sPointerTrackerQueue.add(this);
  onDownEventInternal(x,y,eventTime);
  if (!sGestureEnabler.shouldHandleGesture()) {
    return;
  }
  mIsDetectingGesture=(mKeyboard != null) && mKeyboard.mId.isAlphabetKeyboard() && key != null && !key.isModifier();
  if (mIsDetectingGesture) {
    mBatchInputArbiter.addDownEventPoint(x,y,eventTime,sTypingTimeRecorder.getLastLetterTypingTime(),getActivePointerTrackerCount());
    mGestureStrokeDrawingPoints.onDownEvent(x,y,mBatchInputArbiter.getElapsedTimeSinceFirstDown(eventTime));
  }
}

Fixed version (ground truth):
private void onDownEvent(final int x,final int y,final long eventTime,final KeyDetector keyDetector){
  setKeyDetectorInner(keyDetector);
  if (DEBUG_EVENT) {
    printTouchEvent("String_Node_Str",x,y,eventTime);
  }
  final long deltaT=eventTime - mUpTime;
  if (deltaT < sParams.mTouchNoiseThresholdTime) {
    final int distance=getDistance(x,y,mLastX,mLastY);
    if (distance < sParams.mTouchNoiseThresholdDistance) {
      if (DEBUG_MODE)       Log.w(TAG,String.format("String_Node_Str" + "String_Node_Str",mPointerId,deltaT,distance));
      cancelTrackingForAction();
      return;
    }
  }
  final Key key=getKeyOn(x,y);
  mBogusMoveEventDetector.onActualDownEvent(x,y);
  if (key != null && key.isModifier()) {
    sPointerTrackerQueue.releaseAllPointers(eventTime);
  }
  sPointerTrackerQueue.add(this);
  onDownEventInternal(x,y,eventTime);
  if (!sGestureEnabler.shouldHandleGesture()) {
    return;
  }
  mIsDetectingGesture=(mKeyboard != null) && mKeyboard.mId.isAlphabetKeyboard() && key != null && !key.isModifier();
  if (mIsDetectingGesture) {
    mBatchInputArbiter.addDownEventPoint(x,y,eventTime,sTypingTimeRecorder.getLastLetterTypingTime(),getActivePointerTrackerCount());
    mGestureStrokeDrawingPoints.onDownEvent(x,y,mBatchInputArbiter.getElapsedTimeSinceFirstDown(eventTime));
  }
}
Program: 87398
Project: 87398
Buggy source:
/** 
 * Create an combiner chain. The combiner chain takes events as inputs and outputs code points and combining state. For example, if the input language is Japanese, the combining chain will typically perform kana conversion.
 * @param combinerList A list of combiners to be applied in order.
 */
public CombinerChain(final Combiner... combinerList){
  mCombiners=CollectionUtils.newArrayList();
  mCombiners.add(new DeadKeyCombiner());
  for (  final Combiner combiner : combinerList) {
    mCombiners.add(combiner);
  }
  mCombinedText=new StringBuilder();
  mStateFeedback=new SpannableStringBuilder();
}

Fixed version (ground truth):
/** 
 * Create an combiner chain. The combiner chain takes events as inputs and outputs code points and combining state. For example, if the input language is Japanese, the combining chain will typically perform kana conversion. This takes a string for initial text, taken to be present before the cursor: we'll start after this.
 * @param initialText The text that has already been combined so far.
 * @param combinerList A list of combiners to be applied in order.
 */
public CombinerChain(final String initialText,final Combiner... combinerList){
  mCombiners=CollectionUtils.newArrayList();
  mCombiners.add(new DeadKeyCombiner());
  for (  final Combiner combiner : combinerList) {
    mCombiners.add(combiner);
  }
  mCombinedText=new StringBuilder(initialText);
  mStateFeedback=new SpannableStringBuilder();
}
Program: 87399
Project: 87399
Buggy source:
public WordComposer(){
  mCombinerChain=new CombinerChain();
  mEvents=CollectionUtils.newArrayList();
  mAutoCorrection=null;
  mIsResumed=false;
  mIsBatchMode=false;
  mCursorPositionWithinWord=0;
  mRejectedBatchModeSuggestion=null;
  mPreviousWordForSuggestion=null;
  refreshTypedWordCache();
}

Fixed version (ground truth):
public WordComposer(){
  mCombinerChain=new CombinerChain("String_Node_Str");
  mEvents=CollectionUtils.newArrayList();
  mAutoCorrection=null;
  mIsResumed=false;
  mIsBatchMode=false;
  mCursorPositionWithinWord=0;
  mRejectedBatchModeSuggestion=null;
  mPreviousWordForSuggestion=null;
  refreshTypedWordCache();
}
Program: 87400
Project: 87400
Buggy source:
/** 
 * Initializes the input logic for input in an editor. Call this when input starts or restarts in some editor (typically, in onStartInputView). If the input is starting in the same field as before, set `restarting' to true. This allows the input logic to reset only necessary stuff and save performance. Also, when restarting some things must not be done (for example, the keyboard should not be reset to the alphabetic layout), so do not send false to this just in case.
 * @param restarting whether input is starting in the same field as before. Unused for now.
 * @param editorInfo the editorInfo associated with the editor.
 * @param combiningSpec the combining spec string for this subtype
 */
public void startInput(final boolean restarting,final EditorInfo editorInfo,final String combiningSpec){
  mEnteredText=null;
  mWordComposer.restart(combiningSpec);
  resetComposingState(true);
  mDeleteCount=0;
  mSpaceState=SpaceState.NONE;
  mRecapitalizeStatus.deactivate();
  mCurrentlyPressedHardwareKeys.clear();
  mSuggestedWords=SuggestedWords.EMPTY;
  mConnection.tryFixLyingCursorPosition();
  cancelDoubleSpacePeriodCountdown();
  if (InputLogicHandler.NULL_HANDLER == mInputLogicHandler) {
    mInputLogicHandler=new InputLogicHandler(mLatinIME,this);
  }
 else {
    mInputLogicHandler.reset();
  }
}

Fixed version (ground truth):
/** 
 * Initializes the input logic for input in an editor. Call this when input starts or restarts in some editor (typically, in onStartInputView). If the input is starting in the same field as before, set `restarting' to true. This allows the input logic to reset only necessary stuff and save performance. Also, when restarting some things must not be done (for example, the keyboard should not be reset to the alphabetic layout), so do not send false to this just in case.
 * @param restarting whether input is starting in the same field as before. Unused for now.
 * @param editorInfo the editorInfo associated with the editor.
 * @param combiningSpec the combining spec string for this subtype
 */
public void startInput(final boolean restarting,final EditorInfo editorInfo,final String combiningSpec){
  mEnteredText=null;
  mWordComposer.restartCombining(combiningSpec);
  resetComposingState(true);
  mDeleteCount=0;
  mSpaceState=SpaceState.NONE;
  mRecapitalizeStatus.deactivate();
  mCurrentlyPressedHardwareKeys.clear();
  mSuggestedWords=SuggestedWords.EMPTY;
  mConnection.tryFixLyingCursorPosition();
  cancelDoubleSpacePeriodCountdown();
  if (InputLogicHandler.NULL_HANDLER == mInputLogicHandler) {
    mInputLogicHandler=new InputLogicHandler(mLatinIME,this);
  }
 else {
    mInputLogicHandler.reset();
  }
}
Program: 87401
Project: 87401
Buggy source:
/** 
 * Call this when the subtype changes.
 * @param combiningSpec the spec string for the combining rules
 */
public void onSubtypeChanged(final String combiningSpec){
  mWordComposer.restart(combiningSpec);
}

Fixed version (ground truth):
/** 
 * Call this when the subtype changes.
 * @param combiningSpec the spec string for the combining rules
 */
public void onSubtypeChanged(final String combiningSpec){
  mWordComposer.restartCombining(combiningSpec);
}
Program: 87402
Project: 87402
Buggy source:
public CombinerChain(final Combiner... combinerList){
}

Fixed version (ground truth):
public CombinerChain(final String initialText,final Combiner... combinerList){
  mComposingWord=new StringBuilder(initialText);
}
Program: 87403
Project: 87403
Buggy source:
/** 
 * Create an combiner chain. The combiner chain takes events as inputs and outputs code points and combining state. For example, if the input language is Japanese, the combining chain will typically perform kana conversion.
 * @param combinerList A list of combiners to be applied in order.
 */
public CombinerChain(final Combiner... combinerList){
  mCombiners=CollectionUtils.newArrayList();
  mCombiners.add(new DeadKeyCombiner());
  for (  final Combiner combiner : combinerList) {
    mCombiners.add(combiner);
  }
  mCombinedText=new StringBuilder();
  mStateFeedback=new SpannableStringBuilder();
}

Fixed version (ground truth):
/** 
 * Create an combiner chain. The combiner chain takes events as inputs and outputs code points and combining state. For example, if the input language is Japanese, the combining chain will typically perform kana conversion. This takes a string for initial text, taken to be present before the cursor: we'll start after this.
 * @param initialText The text that has already been combined so far.
 * @param combinerList A list of combiners to be applied in order.
 */
public CombinerChain(final String initialText,final Combiner... combinerList){
  mCombiners=CollectionUtils.newArrayList();
  mCombiners.add(new DeadKeyCombiner());
  for (  final Combiner combiner : combinerList) {
    mCombiners.add(combiner);
  }
  mCombinedText=new StringBuilder(initialText);
  mStateFeedback=new SpannableStringBuilder();
}
Program: 87404
Project: 87404
Buggy source:
public WordComposer(){
  mCombinerChain=new CombinerChain();
  mEvents=CollectionUtils.newArrayList();
  mAutoCorrection=null;
  mIsResumed=false;
  mIsBatchMode=false;
  mCursorPositionWithinWord=0;
  mRejectedBatchModeSuggestion=null;
  mPreviousWordForSuggestion=null;
  refreshTypedWordCache();
}

Fixed version (ground truth):
public WordComposer(){
  mCombinerChain=new CombinerChain("String_Node_Str");
  mEvents=CollectionUtils.newArrayList();
  mAutoCorrection=null;
  mIsResumed=false;
  mIsBatchMode=false;
  mCursorPositionWithinWord=0;
  mRejectedBatchModeSuggestion=null;
  mPreviousWordForSuggestion=null;
  refreshTypedWordCache();
}
Program: 87405
Project: 87405
Buggy source:
/** 
 * Initializes the input logic for input in an editor. Call this when input starts or restarts in some editor (typically, in onStartInputView). If the input is starting in the same field as before, set `restarting' to true. This allows the input logic to reset only necessary stuff and save performance. Also, when restarting some things must not be done (for example, the keyboard should not be reset to the alphabetic layout), so do not send false to this just in case.
 * @param restarting whether input is starting in the same field as before. Unused for now.
 * @param editorInfo the editorInfo associated with the editor.
 * @param combiningSpec the combining spec string for this subtype
 */
public void startInput(final boolean restarting,final EditorInfo editorInfo,final String combiningSpec){
  mEnteredText=null;
  mWordComposer.restart(combiningSpec);
  resetComposingState(true);
  mDeleteCount=0;
  mSpaceState=SpaceState.NONE;
  mRecapitalizeStatus.deactivate();
  mCurrentlyPressedHardwareKeys.clear();
  mSuggestedWords=SuggestedWords.EMPTY;
  mConnection.tryFixLyingCursorPosition();
  cancelDoubleSpacePeriodCountdown();
  if (InputLogicHandler.NULL_HANDLER == mInputLogicHandler) {
    mInputLogicHandler=new InputLogicHandler(mLatinIME,this);
  }
 else {
    mInputLogicHandler.reset();
  }
}

Fixed version (ground truth):
/** 
 * Initializes the input logic for input in an editor. Call this when input starts or restarts in some editor (typically, in onStartInputView). If the input is starting in the same field as before, set `restarting' to true. This allows the input logic to reset only necessary stuff and save performance. Also, when restarting some things must not be done (for example, the keyboard should not be reset to the alphabetic layout), so do not send false to this just in case.
 * @param restarting whether input is starting in the same field as before. Unused for now.
 * @param editorInfo the editorInfo associated with the editor.
 * @param combiningSpec the combining spec string for this subtype
 */
public void startInput(final boolean restarting,final EditorInfo editorInfo,final String combiningSpec){
  mEnteredText=null;
  mWordComposer.restartCombining(combiningSpec);
  resetComposingState(true);
  mDeleteCount=0;
  mSpaceState=SpaceState.NONE;
  mRecapitalizeStatus.deactivate();
  mCurrentlyPressedHardwareKeys.clear();
  mSuggestedWords=SuggestedWords.EMPTY;
  mConnection.tryFixLyingCursorPosition();
  cancelDoubleSpacePeriodCountdown();
  if (InputLogicHandler.NULL_HANDLER == mInputLogicHandler) {
    mInputLogicHandler=new InputLogicHandler(mLatinIME,this);
  }
 else {
    mInputLogicHandler.reset();
  }
}
Program: 87406
Project: 87406
Buggy source:
/** 
 * Call this when the subtype changes.
 * @param combiningSpec the spec string for the combining rules
 */
public void onSubtypeChanged(final String combiningSpec){
  mWordComposer.restart(combiningSpec);
}

Fixed version (ground truth):
/** 
 * Call this when the subtype changes.
 * @param combiningSpec the spec string for the combining rules
 */
public void onSubtypeChanged(final String combiningSpec){
  mWordComposer.restartCombining(combiningSpec);
}
Program: 87407
Project: 87407
Buggy source:
public CombinerChain(final Combiner... combinerList){
}

Fixed version (ground truth):
public CombinerChain(final String initialText,final Combiner... combinerList){
  mComposingWord=new StringBuilder(initialText);
}
Program: 87409
Project: 87409
Buggy source:
/** 
 * Copy the code points in the typed word to a destination array of ints. If the array is too small to hold the code points in the typed word, nothing is copied and -1 is returned.
 * @param destination the array of ints.
 * @param maxSize the size of the array.
 * @return the number of copied code points.
 */
public int copyCodePointsExceptTrailingSingleQuotesAndReturnCodePointCount(final int[] destination,final int maxSize){
  final int i=mTypedWordCache.length() - 1 - trailingSingleQuotesCount();
  if (i < 0) {
    return 0;
  }
  final int codePointSize=Character.codePointCount(mTypedWordCache,0,i);
  if (codePointSize > maxSize) {
    return -1;
  }
  return StringUtils.copyCodePointsAndReturnCodePointCount(destination,mTypedWordCache,0,i + 1,true);
}

Fixed version (ground truth):
/** 
 * Copy the code points in the typed word to a destination array of ints. If the array is too small to hold the code points in the typed word, nothing is copied and -1 is returned.
 * @param destination the array of ints.
 * @return the number of copied code points.
 */
public int copyCodePointsExceptTrailingSingleQuotesAndReturnCodePointCount(final int[] destination){
  final int lastIndex=mTypedWordCache.length() - trailingSingleQuotesCount();
  if (lastIndex <= 0) {
    return 0;
  }
  final int codePointSize=Character.codePointCount(mTypedWordCache,0,lastIndex);
  if (codePointSize > destination.length) {
    return -1;
  }
  return StringUtils.copyCodePointsAndReturnCodePointCount(destination,mTypedWordCache,0,lastIndex,true);
}
Program: 87411
Project: 87411
Buggy source:
/** 
 * Copy the code points in the typed word to a destination array of ints. If the array is too small to hold the code points in the typed word, nothing is copied and -1 is returned.
 * @param destination the array of ints.
 * @param maxSize the size of the array.
 * @return the number of copied code points.
 */
public int copyCodePointsExceptTrailingSingleQuotesAndReturnCodePointCount(final int[] destination,final int maxSize){
  final int i=mTypedWordCache.length() - 1 - trailingSingleQuotesCount();
  if (i < 0) {
    return 0;
  }
  final int codePointSize=Character.codePointCount(mTypedWordCache,0,i);
  if (codePointSize > maxSize) {
    return -1;
  }
  return StringUtils.copyCodePointsAndReturnCodePointCount(destination,mTypedWordCache,0,i + 1,true);
}

Fixed version (ground truth):
/** 
 * Copy the code points in the typed word to a destination array of ints. If the array is too small to hold the code points in the typed word, nothing is copied and -1 is returned.
 * @param destination the array of ints.
 * @return the number of copied code points.
 */
public int copyCodePointsExceptTrailingSingleQuotesAndReturnCodePointCount(final int[] destination){
  final int lastIndex=mTypedWordCache.length() - trailingSingleQuotesCount();
  if (lastIndex <= 0) {
    return 0;
  }
  final int codePointSize=Character.codePointCount(mTypedWordCache,0,lastIndex);
  if (codePointSize > destination.length) {
    return -1;
  }
  return StringUtils.copyCodePointsAndReturnCodePointCount(destination,mTypedWordCache,0,lastIndex,true);
}
Program: 87413
Project: 87413
Buggy source:
public void testDoubleSpace(){
  final String[] STRINGS_TO_TYPE=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final String[] EXPECTED_RESULTS=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (int i=0; i < STRINGS_TO_TYPE.length; ++i) {
    mEditText.setText("String_Node_Str");
    type(STRINGS_TO_TYPE[i]);
    assertEquals("String_Node_Str",EXPECTED_RESULTS[i],mEditText.getText().toString());
  }
}

Fixed version (ground truth):
public void testDoubleSpace(){
  setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD,true,true);
  final String[] STRINGS_TO_TYPE=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final String[] EXPECTED_RESULTS=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (int i=0; i < STRINGS_TO_TYPE.length; ++i) {
    mEditText.setText("String_Node_Str");
    type(STRINGS_TO_TYPE[i]);
    assertEquals("String_Node_Str",EXPECTED_RESULTS[i],mEditText.getText().toString());
  }
}
Program: 87414
Project: 87414
Buggy source:
@Override protected void tearDown() throws Exception {
  mLatinIME.mHandler.removeAllMessages();
  setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS,mPreviousBigramPredictionSettings,true);
  setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD,mPreviousAutoCorrectSetting,DEFAULT_AUTO_CORRECTION_THRESHOLD);
  setDebugMode(mPreviousDebugSetting);
  super.tearDown();
}

Fixed version (ground truth):
@Override protected void tearDown() throws Exception {
  mLatinIME.mHandler.removeAllMessages();
  setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS,mPreviousBigramPredictionSettings,true);
  setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD,mPreviousAutoCorrectSetting,DEFAULT_AUTO_CORRECTION_THRESHOLD);
  setDebugMode(false);
  super.tearDown();
}