int (int textOffset) { String text = toString(); char prev = textOffset <= 0 ? ' ' : text.charAt(textOffset - 1); char next = textOffset >= text.length() ? ' ' : text.charAt(textOffset); boolean leanForward = (Character.isWhitespace(prev) || !Character.isWhitespace(next)) && (!Character.isLetterOrDigit(prev) || Character.isLetterOrDigit(next)); return textOffsetToFile(textOffset, leanForward); }