Program: 35073
Project: 35073
Buggy source:
/** 
 * This function will try to add a number or operator, or entire result list to the current expression Note that there is lots of error checking to be sure user can't entire an invalid operator/number
 * @param sKey should only be single valid number or operator character, or longer previous results
 */
public void keyPresses(String sKey){
  if (sKey.length() > 1) {
    if (isInvalid(sKey))     return;
    if (mSolved)     replaceExpression(sKey);
 else     insertAtSelection(sKey);
    mSolved=false;
    return;
  }
  if (mSolved && sKey.matches("String_Node_Str"))   clearExpression();
  if (!isEntryValid(sKey))   return;
  if (sKey.equals("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.equals("String_Node_Str"))   if (numOpenPara() <= 0) {
    addToExpressionStart("String_Node_Str");
    markHighlighted(0,getSelectionEnd());
  }
  if (sKey.matches(regexAnyValidOperator) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + regexAnyValidOperator+ "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
    backspaceAtSelection();
  }
 else   if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
  }
  insertAtSelection(sKey);
  mSolved=false;
}

Fixed version (ground truth):
/** 
 * This function will try to add a number or operator, or entire result list to the current expression Note that there is lots of error checking to be sure user can't entire an invalid operator/number
 * @param sKey should only be single valid number or operator character, or longer previous results
 */
public void keyPresses(String sKey){
  clearHighlighted();
  if (sKey.length() > 1) {
    if (isInvalid(sKey))     return;
    if (mSolved)     replaceExpression(sKey);
 else     insertAtSelection(sKey);
    mSolved=false;
    return;
  }
  if (mSolved && sKey.matches("String_Node_Str"))   clearExpression();
  if (!isEntryValid(sKey))   return;
  if (sKey.equals("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.equals("String_Node_Str"))   if (numOpenPara() <= 0) {
    addToExpressionStart("String_Node_Str");
    markHighlighted(0,getSelectionEnd());
  }
  if (sKey.matches(regexAnyValidOperator) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + regexAnyValidOperator+ "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
    backspaceAtSelection();
  }
 else   if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
  }
  insertAtSelection(sKey);
  highlightMatchingPara(sKey);
  mSolved=false;
}