diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java index eeac82f9942b..3781d080c952 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java @@ -22,6 +22,7 @@ import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diff.impl.patch.PatchReader; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsApplicationSettings; +import com.intellij.openapi.wm.IdeFrame; import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; @@ -43,6 +44,19 @@ public class PatchClipboardTracker extends ApplicationComponent.Adapter { } private static class PatchClipboardListener extends ClipboardAnalyzeListener { + @Override + public void applicationActivated(IdeFrame ideFrame) { + // we can't get clipboard details especially content size, so we should avoid clipboard processing when it's possible; + if (!VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY) return; + super.applicationActivated(ideFrame); + } + + @Override + public void applicationDeactivated(IdeFrame ideFrame) { + if (!VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY) return; + super.applicationDeactivated(ideFrame); + } + @Override protected void handle(@NotNull Project project, @NotNull String value) { new ApplyPatchFromClipboardAction.MyApplyPatchFromClipboardDialog(project, value).show(); @@ -50,7 +64,6 @@ public class PatchClipboardTracker extends ApplicationComponent.Adapter { @Override public boolean canHandle(@NotNull String value) { - if (!VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY) return false; return PatchReader.isPatchContent(value); } }