@Override
	public void undoableEditHappened(UndoableEditEvent undoableEditEvent) {
		UndoableEdit edit = undoableEditEvent.getEdit();

		// Make sure this event is a document event
		if (edit instanceof DefaultDocumentEvent) {
			// Get the event type
			DefaultDocumentEvent event = (DefaultDocumentEvent) edit;
			EventType eventType = event.getType();

			// Check if the event type is not a change on character attributes, but instead an insertion or removal of
			// text.
			if (eventType != EventType.CHANGE) {
				boolean isEndCompoundEdit = false;

				// Check if current compound edit must be ended as it contains at least one new line
				if (eventType == EventType.INSERT) {
					try {
						// Check if the inserted text contains a new line character
						String insertedText = event.getDocument().getText(event.getOffset(), event.getLength());
						isEndCompoundEdit = insertedText.contains("\n");
					} catch (BadLocationException e) {
						e.printStackTrace();
					}
				}

				// Make sure we are not in an explicit marked compound edit
				if (!isCompoundMarkStart) {
					// Check if current compound edit must be ended due to change between insertion or removal change
					isEndCompoundEdit |= (eventType != lastEventType);

					// Check if the current compound edit should be ended and a new one started
					if (isEndCompoundEdit) {
						endCurrentCompoundEdit();
					}
					// Save the last event type
					lastEventType = eventType;
				}

				// Create new compound edit if the current one has been ended or does not exist
				if (currentCompoundEdit == null) {
					newCurrentCompoundEdit();
				}
			}
			// Added event edit to the current compound edit
			if (currentCompoundEdit != null) {
				currentCompoundEdit.addEdit(edit);
			}
		}
		// Update the state of the actions
		updateUndoRedoState();
	}