From 379a1193ba4e8bd76beb8a99b475089d552469a8 Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 4 Feb 2020 21:16:10 +0100 Subject: [PATCH] Fixed missing rounded corner on selection when cursor is at the start of the next line. Signed-off-by: weisj --- .../text/DefaultHighlighterDark/DarkHighlightPainter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java b/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java index c349ecae..3b47de7c 100644 --- a/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java +++ b/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java @@ -377,12 +377,14 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai final boolean extendToStart, final boolean extendToEnd, final boolean endBeforeStart) { if (DEBUG_COLOR) g2d.setColor(Color.GREEN); + boolean rounded = isRounded(c); Insets margin = c.getMargin(); if (r.x + r.width >= c.getWidth() - margin.right - arcSize / 2.0) { int end = c.getWidth() - margin.right; r.width = end - r.x; + if (rounded && extendToEnd) r.width -= arcSize; } - if (isRounded(c)) { + if (rounded) { boolean roundRightTop = endBeforeStart && !extendToEnd; boolean roundLeftBottom = !isFirstLine && !extendToStart; boolean roundLeftTop = isSecondLine && !extendToStart && posStart.x >= r.x + arcSize; @@ -417,6 +419,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai boolean roundTop = isFirstLine || selectionStart; boolean roundBottom = isLastLine || (isSecondLastLine && posEnd.x + posEnd.width <= start + w - arcSize); boolean roundLeftTop = isFirstLine && start == margin.left; + System.out.println(roundBottom); paintRoundRect(g2d, new Rectangle(start, r.y, w, r.height), arcSize, roundLeftTop, roundTop, false, roundBottom); } else {