protected void onFormat(Editable s) {
    String text = removeFormatting(s.toString());

    // Get the selection handle, since we're setting text and that'll overwrite it
    MutableInteger selectionHandle = new MutableInteger(getSelectionStart());

    // Adjust the handle by removing any comas or spacing to the left
    String cs = s.subSequence(0, selectionHandle.intValue()).toString();
    selectionHandle.subtract(TextUtil.countOccurrences(cs, mSolver.getBaseModule().getSeparator()));

    // Update the text with formatted (comas, etc) text
    setText(Html.fromHtml(formatText(text, selectionHandle)));
    setSelection(selectionHandle.intValue());
  }