diff: calculate diff synchronously in color settings

this should fix blinking DiffColorSettingsTest
This commit is contained in:
Aleksey Pivovarov
2015-11-30 12:34:02 +03:00
parent b1f6d9b57f
commit 8866374233
2 changed files with 15 additions and 6 deletions
@@ -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<AnAction> createToolbarActions() {
List<AnAction> group = new ArrayList<AnAction>();
ContainerUtil.addAll(group, ((ActionGroup)ActionManager.getInstance().getAction(IdeActions.DIFF_VIEWER_TOOLBAR)).getChildren(null));
@@ -59,7 +59,12 @@ public class DiffPreviewPanel implements PreviewPanel {
private final EventDispatcher<ColorAndFontSettingsListener> 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);