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)
This commit is contained in:
Denis Zhdanov
2010-11-23 17:18:01 +03:00
parent 4b35b357ab
commit f9808e1294
2 changed files with 13 additions and 18 deletions
@@ -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) {
@@ -65,7 +65,6 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
private final List<SoftWrapAwareDocumentParsingListener> myListeners = new ArrayList<SoftWrapAwareDocumentParsingListener>();
private final List<IncrementalCacheUpdateEvent> myCacheUpdateEvents = new ArrayList<IncrementalCacheUpdateEvent>();
private final List<SoftWrapApplianceStrategy> myApplianceStrategies = new ArrayList<SoftWrapApplianceStrategy>();
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<IncrementalCacheUpdateEvent> events = new ArrayList<IncrementalCacheUpdateEvent>(myCacheUpdateEvents);