int (final int offsetInDecoded, final @NotNull TextRange rangeInsideHost) { int offset = offsetInDecoded + rangeInsideHost.getStartOffset(); if (offset < rangeInsideHost.getStartOffset()) offset = rangeInsideHost.getStartOffset(); if (offset > rangeInsideHost.getEndOffset()) offset = rangeInsideHost.getEndOffset(); return offset; }