ProperTextRange (@NotNull TextRange injected) { int start = injectedToHost(injected.getStartOffset(), false, true); ProperTextRange fixedTextRange = getFixedTextRange(start); if (fixedTextRange != null) { return fixedTextRange; } int end = injectedToHost(injected.getEndOffset(), true, true); if (end < start) { end = injectedToHost(injected.getEndOffset(), false, true); } return new ProperTextRange(start, end); }