[diff] Don't display error stripes twice

This commit is contained in:
Kirill Likhodedov
2012-10-31 15:07:02 +04:00
parent 2abdf4f019
commit 84b42b4c16
2 changed files with 21 additions and 8 deletions
@@ -22,6 +22,7 @@ import com.intellij.openapi.diff.DiffViewer;
import com.intellij.openapi.diff.LineTokenizer;
import com.intellij.openapi.diff.ex.DiffFragment;
import com.intellij.openapi.diff.impl.external.DiffManagerImpl;
import com.intellij.openapi.diff.impl.fragments.Fragment;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
import com.intellij.openapi.diff.impl.util.FocusDiffSide;
import com.intellij.openapi.diff.impl.util.TextDiffType;
@@ -116,9 +117,13 @@ public class DiffUtil {
@NotNull
public static TextDiffType makeTextDiffType(@NotNull LineFragment fragment) {
TextDiffType type = TextDiffType.create(fragment.getType());
if (fragment.getChildrenIterator() != null) {
if (isInlineWrapper(fragment)) {
return TextDiffType.deriveInstanceForInlineWrapperFragment(type);
}
return type;
}
public static boolean isInlineWrapper(@NotNull Fragment fragment) {
return fragment instanceof LineFragment && ((LineFragment)fragment).getChildrenIterator() != null;
}
}
@@ -97,16 +97,27 @@ public abstract class DiffMarkup implements EditorSource, Disposable {
rangeMarker.setGutterIconRenderer(gutterIconRenderer);
}
if (!(fragment instanceof InlineFragment)) {
rangeMarker.setLineMarkerRenderer(DiffLineMarkerRenderer.createInstance(type));
setLineMarkerRenderer(rangeMarker, fragment, type);
setErrorStripes(rangeMarker, fragment, attributes.getErrorStripeColor());
saveHighlighter(rangeMarker);
}
Color stripeBarColor = attributes.getErrorStripeColor();
private static void setErrorStripes(@NotNull RangeHighlighter rangeMarker, @NotNull Fragment fragment, @Nullable Color stripeBarColor) {
if (DiffUtil.isInlineWrapper(fragment)) {
rangeMarker.setErrorStripeMarkColor(null);
}
else {
if (stripeBarColor != null) {
rangeMarker.setErrorStripeMarkColor(stripeBarColor);
rangeMarker.setThinErrorStripeMark(true);
}
}
saveHighlighter(rangeMarker);
}
private static void setLineMarkerRenderer(RangeHighlighter rangeMarker, Fragment fragment, TextDiffType type) {
if (!(fragment instanceof InlineFragment)) {
rangeMarker.setLineMarkerRenderer(DiffLineMarkerRenderer.createInstance(type));
}
}
public void addLineMarker(int line, @Nullable TextDiffType type, SeparatorPlacement separatorPlacement) {
@@ -153,9 +164,6 @@ public abstract class DiffMarkup implements EditorSource, Disposable {
DiffUtil.drawDoubleShadowedLine((Graphics2D)g, x1, x2, y, color);
}
});
if (type.getType().equals(TextDiffTypeEnum.DELETED)) {
marker.setErrorStripeMarkColor(color);
}
return marker;
}