From 3e0e704bdbe30d66fbae1950ff555c1cb88b8a58 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 4 Jun 2018 13:48:26 +0300 Subject: [PATCH] IDEA-193195 vcs: fix "Compare with Local" for renamed files --- .../vcs/changes/actions/ShowDiffWithLocalAction.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffWithLocalAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffWithLocalAction.java index 85f4a46d693b..c520715a9b23 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffWithLocalAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffWithLocalAction.java @@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ChangeListManager; @@ -79,9 +80,18 @@ public class ShowDiffWithLocalAction extends AnAction implements DumbAware, AnAc @Nullable private Change getChangeWithLocal(@NotNull Change c) { ContentRevision revision = myUseBeforeVersion ? c.getBeforeRevision() : c.getAfterRevision(); + ContentRevision otherRevision = myUseBeforeVersion ? c.getAfterRevision() : c.getBeforeRevision(); if (!isValidRevision(revision)) return null; - ContentRevision contentRevision = CurrentContentRevision.create(revision.getFile()); + FilePath filePath = revision.getFile(); + if (filePath.getVirtualFile() == null && otherRevision != null) { + FilePath otherFile = otherRevision.getFile(); + if (otherFile.getVirtualFile() != null) { + filePath = otherFile; + } + } + + ContentRevision contentRevision = CurrentContentRevision.create(filePath); return new Change(revision, contentRevision); }