From f9808e1294e8e0ac7cbb4bd0215be1dfeb6c269d Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Tue, 23 Nov 2010 17:17:28 +0300 Subject: [PATCH] IDEA-61700 Add soft wraps support to VCS window Instructed soft wrap appliance place VCS_DIFF to use the same value as MAIN_EDITOR (results in soft wraps appliance at vcs diff window if necessary) --- .../editor/ex/EditorSettingsExternalizable.java | 14 +++++++++++++- .../mapping/SoftWrapApplianceManager.java | 17 ----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java index 11cb4b0f3ca3..0125d61de1bc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java @@ -151,6 +151,10 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex for (String placeName : placeNames) { try { SoftWrapAppliancePlaces place = SoftWrapAppliancePlaces.valueOf(placeName); + if (place == SoftWrapAppliancePlaces.VCS_DIFF) { + // Don't keep separate setting for vcs diff window for now and let it share the value for main editor. + continue; + } myPlacesToUseSoftWraps.add(place); } catch (IllegalArgumentException e) { @@ -258,7 +262,15 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex } public boolean isUseSoftWraps(@NotNull SoftWrapAppliancePlaces place) { - return myPlacesToUseSoftWraps.contains(place); + if (myPlacesToUseSoftWraps.contains(place)) { + return true; + } + + // For now use soft wraps at vcs diff if they are enabled for the main editors. + if (place == SoftWrapAppliancePlaces.VCS_DIFF) { + return myPlacesToUseSoftWraps.contains(SoftWrapAppliancePlaces.MAIN_EDITOR); + } + return false; } public void setUseSoftWraps(boolean use) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java index c13bfa93ff5c..42ae65b17331 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java @@ -65,7 +65,6 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen private final List myListeners = new ArrayList(); private final List myCacheUpdateEvents = new ArrayList(); - private final List myApplianceStrategies = new ArrayList(); private final ProcessingContext myContext = new ProcessingContext(); private final FontTypesStorage myOffset2fontType = new FontTypesStorage(); @@ -110,28 +109,12 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen myLineWrapPositionStrategy = null; } - /** - * Registers given strategy to use within the current manager. - * - * @param strategy strategy to use during deciding if soft wraps should be recalculated for particular document region. - */ - public void addApplianceStrategy(@NotNull SoftWrapApplianceStrategy strategy) { - myApplianceStrategies.add(strategy); - } - @SuppressWarnings({"ForLoopReplaceableByForEach"}) private void recalculateSoftWraps() { if (myVisibleAreaWidth <= 0 || myCacheUpdateEvents.isEmpty()) { return; } - // Counter-based loop is preferred to for-each in order to avoid unnecessary performance degradation. - for (int i = 0; i < myApplianceStrategies.size(); i++) { - if (!myApplianceStrategies.get(i).processSoftWraps()) { - return; - } - } - myLastDocumentStamp = myEditor.getDocument().getModificationStamp(); // There is a possible case that new dirty regions are encountered during processing, hence, we iterate on regions snapshot here. List events = new ArrayList(myCacheUpdateEvents);