[diff] Fix diff line separators for inline wrappers

* Create correct TextDiffType for line => use inline wrapper color instead of default.
* Don't draw the shadowed line, otherwise it mixes with inline diff highlighting (overdraws 1 top pixel of it with a lighter color).
This commit is contained in:
Kirill Likhodedov
2012-10-31 15:07:03 +04:00
parent 293a287c4c
commit b8a958ed54
2 changed files with 13 additions and 6 deletions
@@ -16,12 +16,13 @@
package com.intellij.openapi.diff.impl.fragments;
import com.intellij.openapi.diff.actions.MergeOperations;
import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.diff.impl.highlighting.DiffMarkup;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.SeparatorPlacement;
import com.intellij.openapi.util.TextRange;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
@@ -79,12 +80,12 @@ public class FragmentHighlighterImpl implements FragmentHighlighter {
otherWrapper.addAction(MergeOperations.mostSensible(otherDocument, document, otherRange, range), otherRange.getStartOffset());
}
private static void addSeparatingLine(final Fragment fragment, DiffMarkup appender, int startLine, int endLine) {
private static void addSeparatingLine(@NotNull LineFragment fragment, @NotNull DiffMarkup appender, int startLine, int endLine) {
if (endLine <= 0) return;
TextDiffTypeEnum type = fragment.getType();
appender.addLineMarker(endLine - 1, type == null ? null : TextDiffType.create(type), SeparatorPlacement.BOTTOM);
appender.addLineMarker(endLine - 1, type == null ? null : DiffUtil.makeTextDiffType(fragment), SeparatorPlacement.BOTTOM);
if (fragment.getRange(appender.getSide()).getLength() > 0) {
appender.addLineMarker(startLine, type == null ? null : TextDiffType.create(type), SeparatorPlacement.TOP);
appender.addLineMarker(startLine, type == null ? null : DiffUtil.makeTextDiffType(fragment), SeparatorPlacement.TOP);
}
}
}
@@ -37,6 +37,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.TextRange;
import com.intellij.util.Consumer;
import com.intellij.util.containers.HashSet;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -143,7 +144,7 @@ public abstract class DiffMarkup implements EditorSource, Disposable {
}
@Nullable
private RangeHighlighter createLineMarker(@Nullable TextDiffType type, int line, SeparatorPlacement placement) {
private RangeHighlighter createLineMarker(@Nullable final TextDiffType type, int line, SeparatorPlacement placement) {
MarkupModel markupModel = getMarkupModel();
Document document = getDocument();
if (markupModel == null || document == null || type == null) {
@@ -161,7 +162,12 @@ public abstract class DiffMarkup implements EditorSource, Disposable {
marker.setLineSeparatorRenderer(new LineSeparatorRenderer() {
@Override
public void drawLine(Graphics g, int x1, int x2, int y) {
DiffUtil.drawDoubleShadowedLine((Graphics2D)g, x1, x2, y, color);
if (type.isInlineWrapper()) {
UIUtil.drawLine((Graphics2D)g, x1, y, x2, y, null, DiffUtil.getFramingColor(color));
}
else {
DiffUtil.drawDoubleShadowedLine((Graphics2D)g, x1, x2, y, color);
}
}
});
return marker;