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()
This commit is contained in:
Aleksey Pivovarov
2015-02-24 19:59:39 +03:00
parent bc4e6880b6
commit c855e3d360
2 changed files with 13 additions and 11 deletions
@@ -815,7 +815,7 @@ public class ContainerUtil extends ContainerUtilRt {
@Nullable
@Contract(pure=true)
public static <T> T find(@NotNull Iterable<? extends T> iterable, final T equalTo) {
public static <T> T find(@NotNull Iterable<? extends T> iterable, @NotNull final T equalTo) {
return find(iterable, new Condition<T>() {
@Override
public boolean value(final T object) {
@@ -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