From d91574b5fefb4dacd259ad04aa9c6bc704f168c8 Mon Sep 17 00:00:00 2001 From: Radu Nedelcu Date: Tue, 14 Jul 2026 20:19:53 +0300 Subject: [PATCH] fix [VCS]: Improve changelist multi selection for Navigation in the diff view IJPL-247915 (cherry picked from commit ec54ba04205f301857629d2035408734faa99078) GitOrigin-RevId: 25efc16a16908ba333198c41fd32fe7681538fb1 --- .../vcs/changes/ChangeViewDiffRequestProcessor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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();