From 28ff0b4a1e4b67494dae5b81ed4b95a523e45817 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 20 May 2015 16:25:28 +0300 Subject: [PATCH] diff: oneside viewer - hide chevrone operations on state invalidation * they will do nothing anyway --- .../tools/fragmented/OnesideDiffChange.java | 1 + .../tools/fragmented/OnesideDiffViewer.java | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffChange.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffChange.java index cdb30e3cad4e..692beef63da3 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffChange.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffChange.java @@ -235,6 +235,7 @@ public class OnesideDiffChange { @Nullable public GutterIconRenderer createRenderer() { + if (myViewer.isStateIsOutOfDate()) return null; if (!myViewer.isEditable(mySide.other(), true)) return null; boolean bothEditable = myViewer.isEditable(mySide, true); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java index 73d94fe41088..eb1487cd6f31 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java @@ -383,6 +383,22 @@ public class OnesideDiffViewer extends TextDiffViewerBase { updateEditorCanBeTyped(); } + @CalledInAwt + protected void markSuppressEditorTyping() { + mySuppressEditorTyping = true; + updateEditorCanBeTyped(); + } + + @CalledInAwt + protected void markStateIsOutOfDate() { + myStateIsOutOfDate = true; + if (myChangedBlockData != null) { + for (OnesideDiffChange diffChange : myChangedBlockData.getDiffChanges()) { + diffChange.updateGutterActions(); + } + } + } + @Nullable private EditorHighlighter buildHighlighter(@Nullable Project project, @NotNull DocumentContent content1, @@ -611,8 +627,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase { if (twosideStartLine == -1 || twosideEndLine == -1) { // this should never happen logDebugInfo(e, onesideStartPosition, onesideEndPosition, twosideStartLine, twosideEndLine); - mySuppressEditorTyping = true; - updateEditorCanBeTyped(); + markSuppressEditorTyping(); return; } @@ -630,7 +645,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase { finally { // TODO: we can avoid marking state out-of-date in some simple cases (like in SimpleDiffViewer) // but this will greatly increase complexity, so let's wait if it's actually required by users - myStateIsOutOfDate = true; + markStateIsOutOfDate(); myFoldingModel.onDocumentChanged(e); scheduleRediff(); @@ -673,9 +688,8 @@ public class OnesideDiffViewer extends TextDiffViewerBase { protected void onDocumentChange(@NotNull DocumentEvent e) { if (myDuringTwosideDocumentModification) return; - myStateIsOutOfDate = true; - mySuppressEditorTyping = true; - updateEditorCanBeTyped(); + markStateIsOutOfDate(); + markSuppressEditorTyping(); myFoldingModel.onDocumentChanged(e); scheduleRediff();