IDEA-212625 diff: fix rendering near soft wrapped lines
GitOrigin-RevId: e0e9151219608890299f26be3cd8ca8f519420a8
@@ -3,6 +3,7 @@ package com.intellij.diff.util;
|
||||
|
||||
import com.intellij.codeInsight.folding.impl.FoldingUtil;
|
||||
import com.intellij.diff.fragments.DiffFragment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
@@ -31,6 +32,8 @@ import java.util.List;
|
||||
import static com.intellij.diff.util.DiffUtil.getLineCount;
|
||||
|
||||
public class DiffDrawUtil {
|
||||
private static final Logger LOG = Logger.getInstance(DiffDrawUtil.class);
|
||||
|
||||
public static final int STRIPE_LAYER = HighlighterLayer.ERROR - 1;
|
||||
public static final int DEFAULT_LAYER = HighlighterLayer.SELECTION - 3;
|
||||
public static final int INLINE_LAYER = HighlighterLayer.SELECTION - 2;
|
||||
@@ -165,7 +168,7 @@ public class DiffDrawUtil {
|
||||
public static int lineToY(@NotNull Editor editor, int line) {
|
||||
Document document = editor.getDocument();
|
||||
if (line >= getLineCount(document)) {
|
||||
int y = lineToY(editor, getLineCount(document) - 1);
|
||||
int y = editor.logicalPositionToXY(editor.offsetToLogicalPosition(document.getTextLength())).y;
|
||||
return y + editor.getLineHeight() * (line - getLineCount(document) + 1);
|
||||
}
|
||||
return editor.logicalPositionToXY(editor.offsetToLogicalPosition(document.getLineStartOffset(line))).y;
|
||||
@@ -237,9 +240,12 @@ public class DiffDrawUtil {
|
||||
int x2 = gutter.getWidth();
|
||||
|
||||
int y = r.y;
|
||||
if (placement == SeparatorPlacement.BOTTOM) y += editor.getLineHeight();
|
||||
if (placement == SeparatorPlacement.BOTTOM) {
|
||||
LOG.warn("BOTTOM gutter line renderers are not supported");
|
||||
y += editor.getLineHeight() - 1;
|
||||
}
|
||||
|
||||
drawChunkBorderLine(g2, x1, x2, y - 1, type.getColor(editor), doubleLine, resolved);
|
||||
drawChunkBorderLine(g2, x1, x2, y, type.getColor(editor), doubleLine, resolved);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -323,7 +329,7 @@ public class DiffDrawUtil {
|
||||
@NotNull
|
||||
public static List<RangeHighlighter> createLineMarker(@NotNull final Editor editor, int line, @NotNull final TextDiffType type) {
|
||||
if (line == 0) return Collections.emptyList();
|
||||
return new LineMarkerBuilder(editor, line - 1, SeparatorPlacement.BOTTOM)
|
||||
return new LineMarkerBuilder(editor, line, SeparatorPlacement.TOP)
|
||||
.withType(type)
|
||||
.withDefaultRenderer(false)
|
||||
.withDefaultGutterRenderer(false)
|
||||
|
||||
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 356 B |
|
Before Width: | Height: | Size: 342 B After Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 309 B After Width: | Height: | Size: 303 B |
|
Before Width: | Height: | Size: 351 B After Width: | Height: | Size: 353 B |
@@ -411,12 +411,11 @@ public class EditorPainter implements TextDrawingCallback {
|
||||
if (separatorColor == null && lineSeparatorRenderer == null) {
|
||||
return;
|
||||
}
|
||||
int line = myDocument.getLineNumber(marker.getLineSeparatorPlacement() == SeparatorPlacement.TOP
|
||||
? marker.getStartOffset()
|
||||
: marker.getEndOffset());
|
||||
int visualLine = myView.offsetToVisualLine(myDocument.getLineStartOffset(line), false);
|
||||
int y = myView.visualLineToY(visualLine) + (marker.getLineSeparatorPlacement() == SeparatorPlacement.TOP ? 0 : myView.getLineHeight())
|
||||
- 1 + yShift;
|
||||
boolean isTop = marker.getLineSeparatorPlacement() == SeparatorPlacement.TOP;
|
||||
int edgeOffset = isTop ? myDocument.getLineStartOffset(myDocument.getLineNumber(marker.getStartOffset()))
|
||||
: myDocument.getLineEndOffset(myDocument.getLineNumber(marker.getEndOffset()));
|
||||
int visualLine = myView.offsetToVisualLine(edgeOffset, !isTop);
|
||||
int y = myView.visualLineToY(visualLine) + (isTop ? 0 : myView.getLineHeight()) - 1 + yShift;
|
||||
int startX = myCorrector.lineSeparatorStart(clip.x);
|
||||
int endX = myCorrector.lineSeparatorEnd(clip.x + clip.width);
|
||||
g.setColor(separatorColor);
|
||||
|
||||
|
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 288 B |