mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[patch]: IDEA-164889 do not process clipboard if not needed
* we can't get content size from clipboard, so it's better to avoid heavy content loading if possible;
This commit is contained in:
+14
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user