From 3b8a4e098e87a7c7716fab2b1d4b8bc586b3d0fb Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 11 Sep 2017 20:05:03 +0300 Subject: [PATCH] diff: do not require Project in "Compare with Selection" action --- .../CompareClipboardWithSelectionAction.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java b/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java index 5ad02ce37b0c..5a75e18a8cce 100644 --- a/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java +++ b/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java @@ -44,16 +44,12 @@ import org.jetbrains.annotations.Nullable; public class CompareClipboardWithSelectionAction extends BaseShowDiffAction { @Nullable private static Editor getEditor(@NotNull AnActionEvent e) { - Project project = e.getProject(); - if (project == null) return null; - Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor != null) return editor; - editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if (editor != null) return editor; - - return null; + Project project = e.getProject(); + if (project == null) return null; + return FileEditorManager.getInstance(project).getSelectedTextEditor(); } @Nullable @@ -81,7 +77,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction { @Nullable @Override protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) { - Project project = e.getRequiredData(CommonDataKeys.PROJECT); + Project project = e.getProject(); Editor editor = getEditor(e); FileType editorFileType = getEditorFileType(e); assert editor != null; @@ -103,7 +99,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction { } @NotNull - private static DocumentContent createContent(@NotNull Project project, @NotNull Editor editor, @Nullable FileType type) { + private static DocumentContent createContent(@Nullable Project project, @NotNull Editor editor, @Nullable FileType type) { DocumentContent content = DiffContentFactory.getInstance().create(project, editor.getDocument(), type); SelectionModel selectionModel = editor.getSelectionModel();