diff --git a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java index ac96ed63bdce..aa8edd6098bb 100644 --- a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java @@ -16,6 +16,8 @@ package com.intellij.diff.merge; import com.intellij.diff.DiffContext; +import com.intellij.diff.DiffDialogHints; +import com.intellij.diff.DiffManager; import com.intellij.diff.FrameDiffTool; import com.intellij.diff.actions.ProxyUndoRedoAction; import com.intellij.diff.comparison.ComparisonManager; @@ -55,6 +57,7 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.LineTokenizer; import com.intellij.openapi.util.text.StringUtil; @@ -103,7 +106,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { final DocumentContent right = ThreeSide.RIGHT.select(contents); final DocumentContent output = mergeRequest.getOutputContent(); - return ContainerUtil.list(left, output, right); + return ContainerUtil.list(left, output, right); } @NotNull @@ -223,10 +226,15 @@ public class TextMergeViewer implements MergeTool.MergeViewer { group.add(new MyToggleAutoScrollAction()); group.add(myEditorSettingsAction); - group.add(Separator.getInstance()); - group.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_BASE)); - group.add(new TextShowPartialDiffAction(PartialDiffMode.BASE_RIGHT)); - group.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_RIGHT)); + DefaultActionGroup diffGroup = new DefaultActionGroup("Compare With", true); + diffGroup.getTemplatePresentation().setIcon(AllIcons.Diff.Diff); + diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_BASE)); + diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.BASE_RIGHT)); + diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_RIGHT)); + diffGroup.add(new ShowDiffWithBaseAction(ThreeSide.LEFT)); + diffGroup.add(new ShowDiffWithBaseAction(ThreeSide.BASE)); + diffGroup.add(new ShowDiffWithBaseAction(ThreeSide.RIGHT)); + group.add(diffGroup); group.add(Separator.getInstance()); group.add(new ApplyNonConflictsAction(ThreeSide.BASE)); @@ -1146,6 +1154,35 @@ public class TextMergeViewer implements MergeTool.MergeViewer { } } + private class ShowDiffWithBaseAction extends DumbAwareAction { + @NotNull private final ThreeSide mySide; + + public ShowDiffWithBaseAction(@NotNull ThreeSide side) { + mySide = side; + String actionId = mySide.select("Diff.CompareWithBase.Left", "Diff.CompareWithBase.Result", "Diff.CompareWithBase.Right"); + ActionUtil.copyFrom(this, actionId); + } + + @Override + public void actionPerformed(AnActionEvent e) { + DiffContent baseContent = ThreeSide.BASE.select(myMergeRequest.getContents()); + String baseTitle = ThreeSide.BASE.select(myMergeRequest.getContentTitles()); + + DiffContent otherContent = mySide.select(myRequest.getContents()); + String otherTitle = mySide.select(myRequest.getContentTitles()); + + SimpleDiffRequest request = new SimpleDiffRequest(myRequest.getTitle(), baseContent, otherContent, baseTitle, otherTitle); + + ThreeSide currentSide = getCurrentSide(); + LogicalPosition currentPosition = DiffUtil.getCaretPosition(getCurrentEditor()); + + LogicalPosition resultPosition = transferPosition(currentSide, mySide, currentPosition); + request.putUserData(DiffUserDataKeys.SCROLL_TO_LINE, Pair.create(Side.RIGHT, resultPosition.line)); + + DiffManager.getInstance().showDiff(myProject, request, new DiffDialogHints(null, myPanel)); + } + } + // // Helpers // diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index a39550047238..7b1b7163efec 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1308,6 +1308,9 @@ action.Diff.ApplyNonConflicts.Right.text=Apply Non-Conflicting Changes from the action.Diff.ComparePartial.Base.Left.text=Compare Left and Middle Contents action.Diff.ComparePartial.Base.Right.text=Compare Middle and Right Contents action.Diff.ComparePartial.Left.Right.text=Compare Left and Right Contents +action.Diff.CompareWithBase.Left.text=Compare Base and Left Contents +action.Diff.CompareWithBase.Result.text=Compare Base and Middle Contents +action.Diff.CompareWithBase.Right.text=Compare Base and Right Contents action.FileChooser.ShowHiddens.text=Show Hidden Files and Directories action.FileChooser.ShowHiddens.description=Show hidden files and directories diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 59352461aac1..c4f5987ff5bd 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -203,6 +203,10 @@ + + + +