void (final @NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { if (caret == null && editor.getCaretModel().getCaretCount() > 1) { editor.getCaretModel().runForEachCaret(c -> c.setSelection(c.getOffset(), getEndOffset(c))); // We don't support kill-ring operations for multiple carets currently EditorCopyPasteHelper.getInstance().copySelectionToClipboard(editor); EditorModificationUtil.deleteSelectedTextForAllCarets(editor); } else { if (caret == null) { caret = editor.getCaretModel().getCurrentCaret(); } int startOffset = caret.getOffset(); int endOffset = getEndOffset(caret); KillRingUtil.cut(editor, startOffset, endOffset); // in case the caret was in the virtual space, we force it to go back to the real offset caret.moveToOffset(startOffset); } }