diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeViewDiffRequestProcessor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeViewDiffRequestProcessor.java index a2d600874139..cb73ce268ab6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeViewDiffRequestProcessor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeViewDiffRequestProcessor.java @@ -143,21 +143,25 @@ public abstract class ChangeViewDiffRequestProcessor extends CacheDiffRequestPro public void refresh() { List selectedChanges = getSelectedChanges(); + Wrapper selectedChange = myCurrentChange != null ? ContainerUtil.find(selectedChanges, myCurrentChange) : null; + if (selectedChange == null && + myCurrentChange != null && + getContext().isWindowFocused() && + getContext().isFocusedInWindow()) { + // Do not automatically switch focused viewer + if (selectedChanges.size() == 1 && getAllChanges().contains(myCurrentChange)) { + selectChange(myCurrentChange); // Restore selection if necessary + } + return; + } + if (selectedChanges.isEmpty()) { myCurrentChange = null; updateRequest(); return; } - Wrapper selectedChange = myCurrentChange != null ? ContainerUtil.find(selectedChanges, myCurrentChange) : null; if (selectedChange == null) { - if (myCurrentChange != null && getContext().isWindowFocused() && getContext().isFocusedInWindow()) { // Do not automatically switch file if focused - if (selectedChanges.size() == 1 && getAllChanges().contains(myCurrentChange)) { - selectChange(myCurrentChange); // Restore selection if necessary - } - return; - } - myCurrentChange = selectedChanges.get(0); updateRequest(); return;