RTEditor/src/main/java/com/onegravity/rteditor/RTOperationManager.java
synchronized void executed(RTEditText editor, Operation op) {
        Stack<Operation> undoStack = getUndoStack(editor);
        Stack<Operation> redoStack = getRedoStack(editor);

        // if operations are executed in a quick succession we "merge" them to have but one
        // -> saves memory and makes more sense from a user perspective (each key stroke an undo? -> no way)
        while (!undoStack.empty() && op.canMerge(undoStack.peek())) {
            Operation previousOp = undoStack.pop();
            op.merge(previousOp);
        }

        push(op, undoStack);
        redoStack.clear();
    }
synchronized void executed(RTEditText editor, Operation op) {
        Stack<Operation> undoStack = getUndoStack(editor);
        Stack<Operation> redoStack = getRedoStack(editor);

        // if operations are executed in a quick succession we "merge" them to have but one
        // -> saves memory and makes more sense from a user perspective (each key stroke an undo? -> no way)
        while (!undoStack.empty() && op.canMerge(undoStack.peek())) {
            Operation previousOp = undoStack.pop();
            op.merge(previousOp);
        }

        push(op, undoStack);
        redoStack.clear();
    }
synchronized void executed ( RTEditText editor , Operation op ) { Stack < Operation > undoStack = getUndoStack ( editor ) ; Stack < Operation > redoStack = getRedoStack ( editor ) ; // if operations are executed in a quick succession we "merge" them to have but one // -> saves memory and makes more sense from a user perspective (each key stroke an undo? -> no way) while ( ! undoStack . empty ( ) && op . canMerge ( undoStack . peek ( ) ) ) { Operation previousOp = undoStack . pop ( ) ; op . merge ( previousOp ) ; } push ( op , undoStack ) ; redoStack . clear ( ) ; }
Call this when an operation is performed to add it to the undo stack.

@param editor The rich text editor the operation was performed on
@param op     The Operation that was performed
Call this when an operation is performed to add it to the undo stack .