From d0b4a1ca409267d0039c999976075f1dd003d94a Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Fri, 9 Jan 2026 14:22:52 +0100 Subject: [PATCH] Use OfFloat Point values to create precise highlight brackets Because of rounding errors the bracket selection highlight is often inconsistent. Making use of residual values provides precise rectangle values and highlight is consistent across all zooms --- .../jface/text/source/MatchingCharacterPainter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java index f63a54c6c1d..aaf0431f96c 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java @@ -262,12 +262,13 @@ private void draw(final GC gc, final int offset) { // determine the character width separately, because the getTextBounds above // will also include any in-line annotations (e.g. codemining annotations) in the width final String matchingCharacter= fTextWidget.getText(offset, offset); - final int width= gc.textExtent(matchingCharacter).x; - + Point sizePoints= gc.textExtent(matchingCharacter); + sizePoints.y= sizePoints.y - 1; final int height= fTextWidget.getCaret().getSize().y; + Rectangle rectangleOfFloat= Rectangle.of(new Point(bounds.x, bounds.y + bounds.height - height), sizePoints); // draw box around line segment - gc.drawRectangle(bounds.x, bounds.y + bounds.height - height, width, height - 1); + gc.drawRectangle(rectangleOfFloat); } else { fTextWidget.redrawRange(offset, 1, true); }