From fffca6ad71594b9c8c29865d3f0073d2f4ef138e Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Mon, 19 Jan 2026 11:18:52 +0100 Subject: [PATCH 1/2] 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 f63a54c6c1d6..4fb4c881a66f 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 characterBounds= gc.textExtent(matchingCharacter); final int height= fTextWidget.getCaret().getSize().y; + characterBounds.y= height - 1; + Rectangle hightlightingArea= Rectangle.of(new Point(bounds.x, bounds.y + bounds.height - height), characterBounds); // draw box around line segment - gc.drawRectangle(bounds.x, bounds.y + bounds.height - height, width, height - 1); + gc.drawRectangle(hightlightingArea); } else { fTextWidget.redrawRange(offset, 1, true); } From 4d991a520ea3c1ab73fede13bd5f148d0d0a2809 Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Mon, 19 Jan 2026 14:16:42 +0100 Subject: [PATCH 2/2] Increase the height of bracket selection by one point In some zoom level the highlight is too close to the text and cutoff sometimes. --- .../org/eclipse/jface/text/source/MatchingCharacterPainter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4fb4c881a66f..ea2ce7843bbc 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 @@ -264,7 +264,7 @@ private void draw(final GC gc, final int offset) { final String matchingCharacter= fTextWidget.getText(offset, offset); Point characterBounds= gc.textExtent(matchingCharacter); final int height= fTextWidget.getCaret().getSize().y; - characterBounds.y= height - 1; + characterBounds.y= height; Rectangle hightlightingArea= Rectangle.of(new Point(bounds.x, bounds.y + bounds.height - height), characterBounds); // draw box around line segment