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 150ad203a026..6c892484ea82 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 @@ -260,7 +260,7 @@ public abstract class ChangeViewDiffRequestProcessor extends CacheDiffRequestPro protected @Nullable AnAction createGoToChangeAction() { Supplier> changesSupplier = Registry.is("vcs.diff.preview.scope.navigation.to.group") - ? this::getCurrentGroupListSelection + ? this::getGroupOrMultiSelectionListSelection : this::getChanges; return PresentableGoToChangePopupAction.create(changesSupplier::get, new MyGoToChangePopupController()); } @@ -273,11 +273,16 @@ public abstract class ChangeViewDiffRequestProcessor extends CacheDiffRequestPro return Collections.emptyList(); } - private @NotNull ListSelection getCurrentGroupListSelection() { + private @NotNull ListSelection getGroupOrMultiSelectionListSelection() { Wrapper currentChange = getCurrentChange(); if (currentChange == null) { return ListSelection.empty(); } + // If there is an explicit multiple selection (2+ items), scope the navigation to it. + List selectedChanges = ContainerUtil.newArrayList(iterateSelectedChanges()); + if (selectedChanges.size() > 1) { + return ListSelection.create(selectedChanges, currentChange); + } List groupChanges = toListIfNotMany(iterateChangesInSameGroup(currentChange), true); if (groupChanges == null) { return ListSelection.empty();