From c855e3d360bd63a12ad2fb3705ff63a13e92f8b6 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 24 Feb 2015 19:58:41 +0300 Subject: [PATCH] diff: fix refresh of FakeContent * force update current change, if it was fake revision * no need to explicitly listen ChangeListManager - ChangeViewer will receive these changes as well, and will call refresh() --- .../util/containers/ContainerUtil.java | 2 +- .../vcs/changes/CacheChangeProcessor.java | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index 4cb8e83f374c..9f63e177e0a6 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -815,7 +815,7 @@ public class ContainerUtil extends ContainerUtilRt { @Nullable @Contract(pure=true) - public static T find(@NotNull Iterable iterable, final T equalTo) { + public static T find(@NotNull Iterable iterable, @NotNull final T equalTo) { return find(iterable, new Condition() { @Override public boolean value(final T object) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java index 52481d46aae0..f115c3c36f3f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java @@ -25,7 +25,6 @@ import com.intellij.diff.util.WaitingBackgroundableTaskExecutor; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; @@ -34,6 +33,7 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.*; @@ -119,12 +119,6 @@ public abstract class CacheChangeProcessor extends DiffRequestProcessor { } if (change.getBeforeRevision() instanceof FakeRevision || change.getAfterRevision() instanceof FakeRevision) { - ChangeListManager.getInstance(myProject).invokeAfterUpdate(new Runnable() { - @Override - public void run() { - refresh(); // TODO: this could cause diff init in 'hide' state - } - }, InvokeAfterUpdateMode.SILENT, "", ModalityState.current()); return new LoadingDiffRequest(ChangeDiffRequestProducer.getRequestTitle(change)); } @@ -193,9 +187,17 @@ public abstract class CacheChangeProcessor extends DiffRequestProcessor { return; } - if (selectedChanges.contains(myCurrentChange)) return; - myCurrentChange = selectedChanges.get(0); - updateRequest(); + Change selectedChange = myCurrentChange != null ? ContainerUtil.find(selectedChanges, myCurrentChange) : null; + if (selectedChange == null) { + myCurrentChange = selectedChanges.get(0); + updateRequest(); + return; + } + + if (myCurrentChange.getBeforeRevision() instanceof FakeRevision || myCurrentChange.getAfterRevision() instanceof FakeRevision) { + myCurrentChange = selectedChange; + updateRequest(); + } } @Override