int (final int offsetInDecoded, final @NotNull TextRange rangeInsideHost) { final int rangeInsideHostStartOffset = rangeInsideHost.getStartOffset(); int displayStart = myHost.physicalToDisplay(rangeInsideHostStartOffset); int i = myHost.displayToPhysical(offsetInDecoded + displayStart); if (i < rangeInsideHostStartOffset) i = rangeInsideHostStartOffset; final int rangeInsideHostEndOffset = rangeInsideHost.getEndOffset(); if (i > rangeInsideHostEndOffset) i = rangeInsideHostEndOffset; return i; }