void (@NotNull Editor editor, @NotNull ProperTextRange range) { assert ApplicationManager.getApplication().isHeadlessEnvironment() : "Must be called in headless mode only"; if (range.getEndOffset() > editor.getDocument().getTextLength()) { throw new IllegalArgumentException("Invalid range: " + range + "; document length: " + editor.getDocument().getTextLength()); } Point viewPositionStart = editor.logicalPositionToXY(editor.offsetToLogicalPosition(range.getStartOffset())); Point viewPositionEnd = editor.logicalPositionToXY(editor.offsetToLogicalPosition(range.getEndOffset())); JScrollPane scrollPane = ComponentUtil.getScrollPane(editor.getContentComponent()); scrollPane.getViewport().setSize(editor.getContentComponent().getWidth(), Math.max(100, viewPositionEnd.y - viewPositionStart.y)); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); scrollPane.getViewport().setViewPosition(viewPositionStart); scrollPane.getViewport().setExtentSize(new Dimension(editor.getContentComponent().getWidth(), Math.max(100, viewPositionEnd.y - viewPositionStart.y))); UIUtil.markAsFocused(editor.getContentComponent(), true); // to make ShowIntentionPass call its collectInformation() }