mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-22363 IDEA-144276 diff: do not show "no differences" in status if all differences ignored
This commit is contained in:
@@ -36,6 +36,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.DiffBundle;
|
||||
import com.intellij.openapi.diff.LineTokenizer;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
@@ -297,12 +298,12 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
|
||||
LineNumberConvertor convertor = builder.getConvertor();
|
||||
List<LineRange> changedLines = builder.getChangedLines();
|
||||
boolean isEqual = builder.isEqual();
|
||||
boolean isContentsEqual = builder.isEqual();
|
||||
|
||||
CombinedEditorData editorData = new CombinedEditorData(builder.getText(), data.getHighlighter(), data.getRangeHighlighter(), fileType,
|
||||
convertor.createConvertor1(), convertor.createConvertor2());
|
||||
|
||||
return apply(editorData, builder.getBlocks(), convertor, changedLines, isEqual);
|
||||
return apply(editorData, builder.getBlocks(), convertor, changedLines, isContentsEqual);
|
||||
}
|
||||
catch (DiffTooBigException e) {
|
||||
return new Runnable() {
|
||||
@@ -377,14 +378,14 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
@NotNull final List<ChangedBlock> blocks,
|
||||
@NotNull final LineNumberConvertor convertor,
|
||||
@NotNull final List<LineRange> changedLines,
|
||||
final boolean isEqual) {
|
||||
final boolean isContentsEqual) {
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myFoldingModel.updateContext(myRequest, getFoldingModelSettings());
|
||||
|
||||
clearDiffPresentation();
|
||||
if (isEqual) myPanel.addNotification(DiffNotifications.createEqualContents());
|
||||
if (isContentsEqual) myPanel.addNotification(DiffNotifications.createEqualContents());
|
||||
|
||||
TIntFunction separatorLines = myFoldingModel.getLineNumberConvertor();
|
||||
myEditor.getGutterComponentEx().setLineNumberConvertor(mergeConverters(data.getLineConvertor1(), separatorLines),
|
||||
@@ -426,7 +427,7 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
guarderRangeBlocks.add(createGuardedBlock(textLength, textLength));
|
||||
}
|
||||
|
||||
myChangedBlockData = new ChangedBlockData(diffChanges, guarderRangeBlocks, convertor);
|
||||
myChangedBlockData = new ChangedBlockData(diffChanges, guarderRangeBlocks, convertor, isContentsEqual);
|
||||
|
||||
myFoldingModel.install(changedLines, myRequest, getFoldingModelSettings());
|
||||
|
||||
@@ -1198,9 +1199,15 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
}
|
||||
|
||||
private class MyStatusPanel extends StatusPanel {
|
||||
@Nullable
|
||||
@Override
|
||||
protected int getChangesCount() {
|
||||
return myChangedBlockData == null ? 0 : myChangedBlockData.getDiffChanges().size();
|
||||
protected String getMessage() {
|
||||
if (myChangedBlockData == null) return null;
|
||||
int changesCount = myChangedBlockData.getDiffChanges().size();
|
||||
if (changesCount == 0 && !myChangedBlockData.isContentsEqual()) {
|
||||
return DiffBundle.message("diff.all.differences.ignored.text");
|
||||
}
|
||||
return DiffBundle.message("diff.count.differences.status.text", changesCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1237,13 +1244,16 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
@NotNull private final List<UnifiedDiffChange> myDiffChanges;
|
||||
@NotNull private final List<RangeMarker> myGuardedRangeBlocks;
|
||||
@NotNull private final LineNumberConvertor myLineNumberConvertor;
|
||||
private final boolean myIsContentsEqual;
|
||||
|
||||
public ChangedBlockData(@NotNull List<UnifiedDiffChange> diffChanges,
|
||||
@NotNull List<RangeMarker> guarderRangeBlocks,
|
||||
@NotNull LineNumberConvertor lineNumberConvertor) {
|
||||
@NotNull LineNumberConvertor lineNumberConvertor,
|
||||
boolean isContentsEqual) {
|
||||
myDiffChanges = diffChanges;
|
||||
myGuardedRangeBlocks = guarderRangeBlocks;
|
||||
myLineNumberConvertor = lineNumberConvertor;
|
||||
myIsContentsEqual = isContentsEqual;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1260,6 +1270,10 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
public LineNumberConvertor getLineNumberConvertor() {
|
||||
return myLineNumberConvertor;
|
||||
}
|
||||
|
||||
public boolean isContentsEqual() {
|
||||
return myIsContentsEqual;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CombinedEditorData {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.DiffBundle;
|
||||
import com.intellij.openapi.diff.DiffNavigationContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -66,6 +67,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
|
||||
@NotNull private final List<SimpleDiffChange> myDiffChanges = new ArrayList<SimpleDiffChange>();
|
||||
@NotNull private final List<SimpleDiffChange> myInvalidDiffChanges = new ArrayList<SimpleDiffChange>();
|
||||
private boolean myIsContentsEqual;
|
||||
|
||||
@NotNull private final MyFoldingModel myFoldingModel;
|
||||
@NotNull private final MyInitialScrollHelper myInitialScrollHelper = new MyInitialScrollHelper();
|
||||
@@ -207,10 +209,10 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
lineFragments = DiffUtil.compare(myRequest, texts[0], texts[1], getDiffConfig(), indicator);
|
||||
}
|
||||
|
||||
boolean isEqualContents = (lineFragments == null || lineFragments.isEmpty()) &&
|
||||
boolean isContentsEqual = (lineFragments == null || lineFragments.isEmpty()) &&
|
||||
StringUtil.equals(texts[0], texts[1]);
|
||||
|
||||
return apply(new CompareData(lineFragments, isEqualContents));
|
||||
return apply(new CompareData(lineFragments, isContentsEqual));
|
||||
}
|
||||
catch (DiffTooBigException e) {
|
||||
return applyNotification(DiffNotifications.createDiffTooBig());
|
||||
@@ -232,7 +234,8 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
myFoldingModel.updateContext(myRequest, getFoldingModelSettings());
|
||||
clearDiffPresentation();
|
||||
|
||||
if (data.isEqualContent()) myPanel.addNotification(DiffNotifications.createEqualContents());
|
||||
myIsContentsEqual = data.isContentsEqual();
|
||||
if (data.isContentsEqual()) myPanel.addNotification(DiffNotifications.createEqualContents());
|
||||
|
||||
if (data.getFragments() != null) {
|
||||
for (LineFragment fragment : data.getFragments()) {
|
||||
@@ -282,6 +285,8 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
//
|
||||
|
||||
private void destroyChangedBlocks() {
|
||||
myIsContentsEqual = false;
|
||||
|
||||
for (SimpleDiffChange change : myDiffChanges) {
|
||||
change.destroyHighlighter();
|
||||
}
|
||||
@@ -862,19 +867,25 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
}
|
||||
|
||||
private class MyStatusPanel extends StatusPanel {
|
||||
@Nullable
|
||||
@Override
|
||||
protected int getChangesCount() {
|
||||
return myDiffChanges.size() + myInvalidDiffChanges.size();
|
||||
protected String getMessage() {
|
||||
if (getHighlightPolicy() == HighlightPolicy.DO_NOT_HIGHLIGHT) return DiffBundle.message("diff.highlighting.disabled.text");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private static class CompareData {
|
||||
@Nullable private final List<LineFragment> myFragments;
|
||||
private final boolean myEqualContent;
|
||||
private final boolean myIsContentsEqual;
|
||||
|
||||
public CompareData(@Nullable List<LineFragment> fragments, boolean equalContent) {
|
||||
public CompareData(@Nullable List<LineFragment> fragments, boolean isContentsEqual) {
|
||||
myFragments = fragments;
|
||||
myEqualContent = equalContent;
|
||||
myIsContentsEqual = isContentsEqual;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -882,8 +893,8 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
return myFragments;
|
||||
}
|
||||
|
||||
public boolean isEqualContent() {
|
||||
return myEqualContent;
|
||||
public boolean isContentsEqual() {
|
||||
return myIsContentsEqual;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.diff.tools.util;
|
||||
|
||||
import com.intellij.openapi.diff.DiffBundle;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ui.AnimatedIcon;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
@@ -62,12 +61,6 @@ public class StatusPanel extends JPanel {
|
||||
|
||||
@Nullable
|
||||
protected String getMessage() {
|
||||
int count = getChangesCount();
|
||||
if (count == -1) return null;
|
||||
return DiffBundle.message("diff.count.differences.status.text", count);
|
||||
}
|
||||
|
||||
protected int getChangesCount() {
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ merge.dialog.cannot.load.file.error.message=Cannot load file: {0}
|
||||
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.count.differences.status.text={0, choice, 0#No differences|1#1 difference|2#{0, number} differences}
|
||||
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
|
||||
binary.files.are.identical.message=Binary files are identical
|
||||
files.are.identical.dialog.title=Files Are Identical
|
||||
|
||||
Reference in New Issue
Block a user