private void handleTab(@Nonnull KeyEvent event) {
		IndexRange selection = codeArea.getSelection();

		// Skip if selection is empty (unless doing shift-tab for unindentation)
		if (selection.getLength() == 0 && !event.isShiftDown()) {
			// Abort if handling tab completion.
			if (handleTabCompletion(event))
				event.consume();

			// Skip tab handling below.
			return;
		}

		// Consume the event so the tab key does not get handled (no insertion of \t)
		event.consume();

		// Detailed selection info.
		TwoDimensional.Position selectionStart2D = codeArea.offsetToPosition(selection.getStart(), TwoDimensional.Bias.Forward);
		TwoDimensional.Position selectionEnd2D = codeArea.offsetToPosition(selection.getEnd(), TwoDimensional.Bias.Forward);
		boolean isMultiLine = selectionStart2D.getMajor() != selectionEnd2D.getMajor();

		// Check if text selection is multi-line
		boolean doShift = false;
		if (isMultiLine) {
			// Insert a '\t' before the first non-whitespace character of all selected paragaphs.
			int start = selection.getStart();
			int end = selection.getEnd();
			int startParagraph = codeArea.offsetToPosition(start, TwoDimensional.Bias.Forward).getMajor();
			int endParagraph = codeArea.offsetToPosition(end, TwoDimensional.Bias.Backward).getMajor();
			for (int i = startParagraph; i <= endParagraph; i++) {
				// Not ideal as it counts as multiple actions (not undo-able in one go) but good enough for now.
				if (event.isShiftDown()) {
					doShift = unindent(i);
				} else {
					doShift = true;
					indent(i);
				}
			}
		} else {
			// Insert a '\t' before the first non-whitespace character of the paragraph.
			int paragraph = codeArea.getCurrentParagraph();
			if (event.isShiftDown()) {
				doShift = unindent(paragraph);
			} else {
				doShift = true;
				indent(paragraph);
			}
		}

		// Re-select the original text.
		if (doShift)
			codeArea.selectRange(selectionStart2D.getMajor(), selectionStart2D.getMinor() + 1,
					selectionEnd2D.getMajor(), selectionEnd2D.getMinor() + 1);
	}
Handles tab events.

@param event
		Key event where {@link KeyCode#TAB} was pressed.
recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/Editor.java