From 25f101b164a6140b50ebb0919b4b76a02f30e490 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 6 Feb 2018 22:13:34 +0300 Subject: [PATCH] diff: show skipped changes as a separate counter in status --- .../diff/tools/simple/SimpleDiffViewer.java | 20 ++++++++++++------- .../src/messages/DiffBundle.properties | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 9620ad0b1fa7..e8b056d24d88 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -63,7 +63,6 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { @NotNull private final StatusPanel myStatusPanel; @NotNull private final List myDiffChanges = new ArrayList<>(); - @NotNull private final List myNonSkippedDiffChanges = new ArrayList<>(); @NotNull private final List myInvalidDiffChanges = new ArrayList<>(); private boolean myIsContentsEqual; @@ -242,11 +241,10 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { SimpleDiffChange change = new SimpleDiffChange(this, fragment, previousFragment, isSkipped); myDiffChanges.add(change); - if (!change.isSkipped()) myNonSkippedDiffChanges.add(change); } } - myFoldingModel.install(myNonSkippedDiffChanges, myRequest, getFoldingModelSettings()); + myFoldingModel.install(getNonSkippedDiffChanges(), myRequest, getFoldingModelSettings()); myInitialScrollHelper.onRediff(); @@ -281,7 +279,6 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { change.destroyHighlighter(); } myDiffChanges.clear(); - myNonSkippedDiffChanges.clear(); for (SimpleDiffChange change : myInvalidDiffChanges) { change.destroyHighlighter(); @@ -323,7 +320,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { @CalledInAwt protected boolean doScrollToChange(@NotNull ScrollToPolicy scrollToPolicy) { - SimpleDiffChange targetChange = scrollToPolicy.select(myNonSkippedDiffChanges); + SimpleDiffChange targetChange = scrollToPolicy.select(getNonSkippedDiffChanges()); if (targetChange == null) targetChange = scrollToPolicy.select(myDiffChanges); if (targetChange == null) return false; @@ -367,6 +364,11 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { return myDiffChanges; } + @NotNull + private List getNonSkippedDiffChanges() { + return ContainerUtil.filter(myDiffChanges, it -> !it.isSkipped()); + } + @NotNull @Override protected SyncScrollSupport.SyncScrollable getSyncScrollable() { @@ -444,7 +446,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { @NotNull @Override protected List getChanges() { - return myNonSkippedDiffChanges; + return getNonSkippedDiffChanges(); } @NotNull @@ -789,11 +791,15 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { if (myTextDiffProvider.isHighlightingDisabled()) { return DiffBundle.message("diff.highlighting.disabled.text"); } + int skippedChanges = ContainerUtil.count(myDiffChanges, it -> it.isSkipped()) + + ContainerUtil.count(myInvalidDiffChanges, it -> it.isSkipped()); int changesCount = myDiffChanges.size() + myInvalidDiffChanges.size(); if (changesCount == 0 && !myIsContentsEqual) { return DiffBundle.message("diff.all.differences.ignored.text"); } - return DiffBundle.message("diff.count.differences.status.text", changesCount); + String message = DiffBundle.message("diff.count.differences.status.text", changesCount - skippedChanges); + if (skippedChanges > 0) message += " " + DiffBundle.message("diff.inactive.count.differences.status.text", skippedChanges); + return message; } } diff --git a/platform/platform-resources-en/src/messages/DiffBundle.properties b/platform/platform-resources-en/src/messages/DiffBundle.properties index 556c0306e285..5f9e9ebb0334 100644 --- a/platform/platform-resources-en/src/messages/DiffBundle.properties +++ b/platform/platform-resources-en/src/messages/DiffBundle.properties @@ -42,6 +42,7 @@ merge.editor.replace.operation.name=Replace merge.editor.insert.operation.name=Insert merge.editor.remove.operation.name=Remove diff.count.differences.status.text={0, choice, 0#No differences|1#1 difference|2#{0, number} differences} +diff.inactive.count.differences.status.text=({0} inactive) diff.all.differences.ignored.text=Differences ignored diff.highlighting.disabled.text=Differences highlighting is off cant.launch.diff.tool.error.message=Can't Launch Diff Tool