void () { Document document = getEditor().getDocument(); int textLength = document.getTextLength(); if (textLength <= 0) return; int offset = myRandom.nextInt(textLength); runWriteCommand(() -> document.deleteString(offset, Math.min(textLength, offset + 1 + myRandom.nextInt(MAX_CHARS_PER_OPERATION)))); }