@Override
	public void selectRange(int anchor, int caretPosition) {
		if (anchor >= 0 && anchor <= getLength() && caretPosition >= 0 && caretPosition <= getLength())
			super.selectRange(anchor, caretPosition);
	}
Code area with additional parameter checks for some common edge cases.

@author Matt Coley
recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/SafeCodeArea.java