@Override
    public void undo() throws CannotUndoException {
      //  End the edit so future edits don't get absorbed by this edit

      if (compoundEdit != null) {
        compoundEdit.end();
      }

      super.undo();

      //  Always start a new compound edit after an undo

      compoundEdit = null;
    }