Skip to content

Commit 5204db3

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 aede341 commit 5204db3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.eclipse.jface.text.source;
1515

1616

17+
1718
import org.eclipse.swt.custom.StyledText;
1819
import org.eclipse.swt.events.PaintEvent;
1920
import org.eclipse.swt.events.PaintListener;
@@ -262,12 +263,12 @@ private void draw(final GC gc, final int offset) {
262263
// determine the character width separately, because the getTextBounds above
263264
// will also include any in-line annotations (e.g. codemining annotations) in the width
264265
final String matchingCharacter= fTextWidget.getText(offset, offset);
265-
final int width= gc.textExtent(matchingCharacter).x;
266+
final Point sizePoints= gc.textExtent(matchingCharacter);
266267

267-
final int height= fTextWidget.getCaret().getSize().y;
268+
Rectangle rectangleOfFloat= Rectangle.of(new Point(bounds.x, bounds.y), sizePoints);
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
}
@@ -473,4 +474,4 @@ private boolean searchForCharacters(String text, ICharacterPairMatcherExtension
473474
return false;
474475
}
475476
}
476-
}
477+
}

0 commit comments

Comments
 (0)