Skip to content

Commit 76ea734

Browse files
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
1 parent e81ba1c commit 76ea734

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,13 @@ private void draw(final GC gc, final int offset) {
262262
// determine the character width separately, because the getTextBounds above
263263
// will also include any in-line annotations (e.g. codemining annotations) in the width
264264
final String matchingCharacter= fTextWidget.getText(offset, offset);
265-
final int width= gc.textExtent(matchingCharacter).x;
266-
265+
Point characterBounds= gc.textExtent(matchingCharacter);
266+
characterBounds.y= characterBounds.y - 1;
267267
final int height= fTextWidget.getCaret().getSize().y;
268+
Rectangle rectangleOfFloat= Rectangle.of(new Point(bounds.x, bounds.y + bounds.height - height), characterBounds);
268269

269270
// draw box around line segment
270-
gc.drawRectangle(bounds.x, bounds.y + bounds.height - height, width, height - 1);
271+
gc.drawRectangle(rectangleOfFloat);
271272
} else {
272273
fTextWidget.redrawRange(offset, 1, true);
273274
}

0 commit comments

Comments
 (0)