fix border painting in presence of inlays

This commit is contained in:
Dmitry Batrak
2017-02-13 17:02:40 +03:00
parent 41bcf88576
commit f75a7b40b9
3 changed files with 10 additions and 2 deletions
@@ -777,8 +777,8 @@ class EditorPainter implements TextDrawingCallback {
}
}
else if (startOffset < maxOffset && endOffset > minOffset) {
float x1 = fragment.offsetToX(Math.max(minOffset, startOffset));
float x2 = fragment.offsetToX(Math.min(maxOffset, endOffset));
float x1 = minOffset == maxOffset ? fragment.getStartX() : fragment.offsetToX(Math.max(minOffset, startOffset));
float x2 = minOffset == maxOffset ? fragment.getEndX() : fragment.offsetToX(Math.min(maxOffset, endOffset));
if (x1 > x2) {
float tmp = x1;
x1 = x2;
Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

@@ -116,6 +116,14 @@ public class EditorPaintingTest extends AbstractEditorTest {
checkResult();
}
public void testMultilineBorderWithInlays() throws Exception {
initText("abc\ndef");
myEditor.getInlayModel().addInlineElement(1, new MyInlayRenderer());
myEditor.getInlayModel().addInlineElement(6, new MyInlayRenderer());
addBorderHighlighter(0, 7, 0, Color.red);
checkResult();
}
private static void setUniformEditorHighlighter(TextAttributes attributes) {
((EditorEx)myEditor).setHighlighter(new UniformHighlighter(attributes));
}