Editor (@NotNull Document document) { Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner); Editor activeEditor = CommonDataKeys.EDITOR.getData(dataContext); if (activeEditor != null && activeEditor.getDocument() != document) { activeEditor = null; } return activeEditor; }