[Demonstration 1]

[Buggy Method]
private void moveCursor(Constants.Direction direction) {
    String currentCode = codeView.getText().toString();
    int cursorPos = currentCode.indexOf(Constants.cursor);
    String preString = currentCode.substring(0, cursorPos);
    String postString;
    if (currentCode.indexOf(Constants.cursor) == currentCode.length() - 1) {
        postString = "";
    } else {
        postString = currentCode.substring(cursorPos + 1);
    }
    if (direction == Constants.Direction.LEFT) {
        int preStringLen = preString.length();
        if (preStringLen == 0)
            return;
        char last = preString.charAt(preStringLen - 1);
        preString = preString.substring(0, preStringLen);
        postString = last + postString;
    } else if (direction == Constants.Direction.RIGHT) {
        int postStringLen = postString.length();
        if (postStringLen == 0)
            return;
        char first = postString.charAt(0);
        postString = postString.substring(1);
        preString = preString + first;
    }
    currentCode = preString + '|' + postString;
    codeView.setText(currentCode);
}

[Buggy Hunk]
preString = preString.substring(0, preStringLen);

[Patch]
preString = preString.substring(0, preStringLen - 1);

[Demonstration 2]

[Buggy Method]
public static String insertWhiteSpaces(String equation) {
    int i = 0;
    String prevToken = null;
    while (i < equation.length()) {
        String currentString = equation.substring(i, i + 1);
        if (isOperator(currentString) || isSpecialChar(equation.charAt(i))) {
            equation = equation.substring(0, i) + " " + equation.substring(i, i + 1) + " " + equation.substring(i + 1, equation.length());
            // inserting a space before and after operator
            // equation.charAt(i) is now a blank space
            // equation.charAt(i+1) is the operator
            // equation.charAt(i+2) is the blank space after operator
            // so we increment i by 2 in here, then by 1 again outside the if
            // to get to the next number in the equation
            if ((prevToken == null || isOperator(prevToken)) && currentString.equals("-")) {
                // i+1 is the minus sign
                i++;
                equation = equation.substring(0, i) + "( 0 " + equation.substring(i, equation.length());
                i += 4;
                // updated i to still be pointing to minus sign
                int j = i + 1;
                // move to next number
                while (j < equation.length() && equation.charAt(j) == ' ') {
                    j++;
                    i++;
                    //						System.out.println("moving to next number");
                }
                // move past next number
                while (j < equation.length() && isNumber(equation.substring(j, j + 1))) {
                    j++;
                    i++;
                    //						System.out.println("moving past next number");
                }
                equation = equation.substring(0, j) + " ) " + equation.substring(j, equation.length());
                //System.out.println("got a negative number boys!");
            }
            i += 2;
        } else // insert white spaces around functions (ie: log, sin, cos, etc)
        if (!isOperator(currentString) && !isSpecialChar(currentString) && !currentString.equals(" ") && !isNumber(currentString) && !currentString.equals(".")) {
            String token = "";
            int j = i;
            String tmpString = equation.substring(j, j + 1);
            while (!isOperator(tmpString) && !isSpecialChar(tmpString) && !tmpString.equals(" ") && j < equation.length()) {
                token += tmpString;
                j++;
                tmpString = equation.substring(j, j + 1);
            }
            equation = insertString(equation, " ", i);
            equation = insertString(equation, " ", i + 1 + token.length());
            i += 1 + token.length();
        }
        prevToken = currentString;
        i++;
    }
    return equation;
}

[Buggy Hunk]
while(j < equation.length() && isNumber(equation.substring(j, j+1))){

[Patch]
while(j < equation.length() && (isNumber(equation.substring(j, j+1)) || equation.substring(j, j+1).equals("."))){

[Demonstration 3]

[Buggy Method]
public void onClick(View view) {
    String equation = equationEditText.getText().toString();
    resultTextView.setText(equation);
}

[Buggy Hunk]
resultTextView.setText(equation);

[Patch]
resultTextView.setText(arithmetic.calculate(equation));