Program: 157573
Project: 157573
Buggy source:
public void onKey(int primaryCode,int[] keyCodes){
  if (DEBUG)   Log.d("String_Node_Str","String_Node_Str" + primaryCode);
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
    handleBackspace();
  break;
case Keyboard.KEYCODE_SHIFT:
handleShift();
break;
case AnyKeyboard.KEYCODE_CTRL:
break;
case AnyKeyboard.KEYCODE_LEFT:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_LEFT);
break;
case AnyKeyboard.KEYCODE_RIGHT:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_RIGHT);
break;
case Keyboard.KEYCODE_CANCEL:
if (mOptionsDialog == null || !mOptionsDialog.isShowing()) {
handleClose();
}
break;
case AnyKeyboardView.KEYCODE_OPTIONS:
showOptionsMenu();
break;
case AnyKeyboard.KEYCODE_SMILEY:
if (mSmileyOnShortPress) {
onText(mConfig.getSmileyText());
}
 else {
if (mInputView != null) mInputView.simulateLongPress(AnyKeyboard.KEYCODE_SMILEY);
}
break;
case AnyKeyboardView.KEYCODE_SMILEY_LONGPRESS:
if (mSmileyOnShortPress) {
if (mInputView != null) mInputView.simulateLongPress(AnyKeyboard.KEYCODE_SMILEY);
}
 else {
onText(mConfig.getSmileyText());
}
break;
case Keyboard.KEYCODE_MODE_CHANGE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Symbols);
break;
case AnyKeyboard.KEYCODE_LANG_CHANGE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
break;
case AnyKeyboard.KEYCODE_ALTER_LAYOUT:
nextAlterKeyboard(getCurrentInputEditorInfo());
break;
case AnyKeyboard.KEYCODE_KEYBOARD_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Any);
break;
case AnyKeyboard.KEYCODE_KEYBOARD_REVERSE_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.PreviousAny);
break;
default :
primaryCode=translatePrimaryCodeFromCurrentKeyboard(primaryCode);
if (mKeyboardSwitcher.isRightToLeftMode()) primaryCode=Workarounds.workaroundParenthesisDirectionFix(primaryCode);
if (isWordSeparator(primaryCode)) {
handleSeparator(primaryCode);
}
 else {
handleCharacter(primaryCode,keyCodes);
mSpaceSent=false;
}
mJustRevertedSeparator=null;
}
}

Fixed version (ground truth):
public void onKey(int primaryCode,int[] keyCodes){
  if (DEBUG)   Log.d("String_Node_Str","String_Node_Str" + primaryCode);
  boolean switchToAlphabetAtTheEnd=false;
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
    handleBackspace();
  break;
case Keyboard.KEYCODE_SHIFT:
handleShift();
break;
case AnyKeyboard.KEYCODE_CTRL:
break;
case AnyKeyboard.KEYCODE_LEFT:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_LEFT);
break;
case AnyKeyboard.KEYCODE_RIGHT:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_RIGHT);
break;
case Keyboard.KEYCODE_CANCEL:
if (mOptionsDialog == null || !mOptionsDialog.isShowing()) {
handleClose();
}
break;
case AnyKeyboardView.KEYCODE_OPTIONS:
showOptionsMenu();
break;
case AnyKeyboard.KEYCODE_SMILEY:
if (mSmileyOnShortPress) {
onText(mConfig.getSmileyText());
}
 else {
if (mInputView != null) mInputView.simulateLongPress(AnyKeyboard.KEYCODE_SMILEY);
}
break;
case AnyKeyboardView.KEYCODE_SMILEY_LONGPRESS:
if (mSmileyOnShortPress) {
if (mInputView != null) mInputView.simulateLongPress(AnyKeyboard.KEYCODE_SMILEY);
}
 else {
onText(mConfig.getSmileyText());
}
break;
case Keyboard.KEYCODE_MODE_CHANGE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Symbols);
break;
case AnyKeyboard.KEYCODE_LANG_CHANGE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
break;
case AnyKeyboard.KEYCODE_ALTER_LAYOUT:
nextAlterKeyboard(getCurrentInputEditorInfo());
break;
case AnyKeyboard.KEYCODE_KEYBOARD_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Any);
break;
case AnyKeyboard.KEYCODE_KEYBOARD_REVERSE_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.PreviousAny);
break;
case KEYCODE_SPACE:
if (DEBUG) Log.d(TAG,"String_Node_Str" + mSwitchKeyboardOnSpace);
if (mSwitchKeyboardOnSpace && !mKeyboardSwitcher.isAlphabetMode()) {
switchToAlphabetAtTheEnd=true;
}
default :
primaryCode=translatePrimaryCodeFromCurrentKeyboard(primaryCode);
if (mKeyboardSwitcher.isRightToLeftMode()) primaryCode=Workarounds.workaroundParenthesisDirectionFix(primaryCode);
if (isWordSeparator(primaryCode)) {
handleSeparator(primaryCode);
}
 else {
handleCharacter(primaryCode,keyCodes);
mSpaceSent=false;
}
mJustRevertedSeparator=null;
if (switchToAlphabetAtTheEnd) {
mKeyboardSwitcher.nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
}
break;
}
}