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