void (@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { if (!editor.getSelectionModel().hasSelection(true)) { DocRenderer.EditorPane pane = DocRenderSelectionManager.getPaneWithSelection(editor); if (pane != null) { String text = pane.getSelectedText(); if (!StringUtil.isEmpty(text)) { Point selectionPositionInEditor = pane.getSelectionPositionInEditor(); if (selectionPositionInEditor != null) { CopyPasteManager.getInstance().setContents(new StringSelection(text)); ScrollingModel scrollingModel = editor.getScrollingModel(); if (!scrollingModel.getVisibleAreaOnScrollingFinished().contains(selectionPositionInEditor)) { scrollingModel.scroll(0, selectionPositionInEditor.y - scrollingModel.getVisibleArea().height / 3); } return; } } } } myOriginalHandler.execute(editor, caret, dataContext); }