From f75a7b40b945426b02ce69be723f879ac1efd17b Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 13 Feb 2017 16:59:32 +0300 Subject: [PATCH] fix border painting in presence of inlays --- .../openapi/editor/impl/view/EditorPainter.java | 4 ++-- .../editor/painting/multilineBorderWithInlays.png | Bin 0 -> 247 bytes .../openapi/editor/EditorPaintingTest.java | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 platform/platform-tests/testData/editor/painting/multilineBorderWithInlays.png diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java index dad69dd5e80e..2aa6f419d302 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java @@ -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; diff --git a/platform/platform-tests/testData/editor/painting/multilineBorderWithInlays.png b/platform/platform-tests/testData/editor/painting/multilineBorderWithInlays.png new file mode 100644 index 0000000000000000000000000000000000000000..b2ed7a1dc5716ae6106c7a820c56299e90250cb7 GIT binary patch literal 247 zcmVs^LWGmYU!${IEn&D$Bq5vhe&Vv$I^X;NN82A8DKS(f$8)y^+ zFYuD2r*AX+`jX90=shy^5Mv@&#LYmj=+JzBHEt_6L1*uBqhm}Y@6S_=}m zXke-s2F`sk!vP0_r^(5VAmUk8kf*2yBJD2)sax8#w*%4hjevAV$^*jOIOAL15f((d x#ce=Rhy61kRPe}vrg(m%{_GJR8%So6>jKra1RYN?0jK}~002ovPDHLkV1lc>V7CAO literal 0 HcmV?d00001 diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java index 8547ed233c30..02df76b1f93b 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java @@ -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)); }