private static @NotNull TextRange updateRange(@NotNull DocumentEvent event, @NotNull TextRange range) {
      if (range.isEmpty()) {
        int newPos = updateOffset(event, range.getEndOffset(), false);
        return newPos == range.getEndOffset() ? range : TextRange.from(newPos, 0);
      }
      int newStart = updateOffset(event, range.getStartOffset(), true);
      int newEnd = updateOffset(event, range.getEndOffset(), false);
      if (range.getStartOffset() == newStart && range.getEndOffset() == newEnd) return range;
      return TextRange.create(newStart, newEnd);
    }
private static @NotNull TextRange updateRange(@NotNull DocumentEvent event, @NotNull TextRange range)