From 88663742339816ec2e2d6d8d1a5d6e7254a18f2c Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 30 Nov 2015 12:22:27 +0300 Subject: [PATCH] diff: calculate diff synchronously in color settings this should fix blinking DiffColorSettingsTest --- .../diff/tools/util/base/DiffViewerBase.java | 14 +++++++++----- .../diff/impl/settings/DiffPreviewPanel.java | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java index d1a6d97ec7a2..96929ad2e752 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java @@ -31,8 +31,8 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.util.Alarm; import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.*; @@ -141,10 +141,7 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { fireEvent(EventType.BEFORE_REDIFF); onBeforeRediff(); - // most of performRediff implementations take ReadLock inside. If EDT is holding write lock - this will never happen, - // and diff will not be calculated. This could happen for diff from FileDocumentManager. - boolean forceEDT = ApplicationManager.getApplication().isWriteAccessAllowed(); - + boolean forceEDT = forceRediffSynchronously(); int waitMillis = trySync || tryRediffSynchronously() ? ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS : 0; myTaskExecutor.executeAndTryWait( @@ -204,6 +201,13 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { return myContext.isWindowFocused(); } + @CalledInAwt + protected boolean forceRediffSynchronously() { + // most of performRediff implementations take ReadLock inside. If EDT is holding write lock - this will never happen, + // and diff will not be calculated. This could happen for diff from FileDocumentManager. + return ApplicationManager.getApplication().isWriteAccessAllowed(); + } + protected List createToolbarActions() { List group = new ArrayList(); ContainerUtil.addAll(group, ((ActionGroup)ActionManager.getInstance().getAction(IdeActions.DIFF_VIEWER_TOOLBAR)).getChildren(null)); diff --git a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java index e7ee5311220e..9827bbe738bb 100644 --- a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java +++ b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java @@ -59,7 +59,12 @@ public class DiffPreviewPanel implements PreviewPanel { private final EventDispatcher myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class); public DiffPreviewPanel(@NotNull Disposable parent) { - myViewer = new SimpleThreesideDiffViewer(new SampleContext(), new SampleRequest()); + myViewer = new SimpleThreesideDiffViewer(new SampleContext(), new SampleRequest()) { + @Override + protected boolean forceRediffSynchronously() { + return true; + } + }; myViewer.init(); Disposer.register(parent, myViewer);