void (@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { SelectionModel selectionModel = editor.getSelectionModel(); if (!selectionModel.hasSelection()) { return; } final int start = selectionModel.getSelectionStart(); final int end = selectionModel.getSelectionEnd(); if (start >= end) { return; } KillRingUtil.copyToKillRing(editor, start, end, false); if (myRemove) { DocumentRunnable runnable = new DocumentRunnable(editor.getDocument(), editor.getProject()) { @Override public void run() { editor.getDocument().deleteString(start, end); } }; if (editor instanceof TextComponentEditor) { runnable.run(); } else { ApplicationManager.getApplication().runWriteAction(runnable); } } }