boolean (@NotNull Editor editor, @NotNull TextRange selectedRange) { TemplateState state = TemplateManagerImpl.getTemplateState(editor); if (state == null) { return false; } for (int i = 0; i < state.getSegmentsCount(); i++) { final TextRange segmentRange = state.getSegmentRange(i); TextRange intersection = segmentRange.intersection(selectedRange); if (intersection == null) { continue; } editor.getSelectionModel().setSelection(intersection.getStartOffset(), intersection.getEndOffset()); return true; } return false; }