TextRange (@NotNull String line, @NotNull TextRange range) { int start = handleSpaces(line, range.getStartOffset(), 1); int end = handleSpaces(line, range.getEndOffset(), -1); if (start != range.getStartOffset() || end != range.getEndOffset()) { return TextRange.create(start, end); } return range; }