String (@NotNull AnActionEvent e) { Editor editor = e.getData(CommonDataKeys.EDITOR); String selectedText = editor != null ? editor.getSelectionModel().getSelectedText() : null; if (selectedText == null) { selectedText = e.getData(JBTerminalWidget.SELECTED_TEXT_DATA_KEY); } return selectedText != null && !selectedText.contains("\n") ? selectedText : null; }