Editor (@NotNull AnActionEvent e) { Project project = e.getProject(); if (project == null) return null; FilePath filePath = e.getData(VcsDataKeys.FILE_PATH); if (filePath == null) return null; VirtualFile virtualFile = filePath.getVirtualFile(); if (virtualFile == null) return null; Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor != null) { VirtualFile editorFile = FileDocumentManager.getInstance().getFile(editor.getDocument()); if (Comparing.equal(editorFile, virtualFile)) return editor; } FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile); if (fileEditor instanceof TextEditor) { return ((TextEditor)fileEditor).getEditor(); } return null; }