MatchingCharacterPainter is using the StyledText.getTextBounds() method to determine the width of the highlight box to draw. This method calculates width based on runs of text, and thus includes the method parameter hints in that width.
This change instead moves to using GC.textExtent() to determine the width of text to highlight, ensuring that only the desired character is highlighted. The character width to highlight was already hard-coded to 1, so now we just pull a single character of text from the desired offset, and pass it to GC.textExtent() to get its width.
Testing
Manual testing
Tested on Windows, running in a normal window
Tested on Windows, on a desktop with 200% font scaling enabled:
Unit testing
I didn't find existing unit tests for MatchingCharacterPainter, and am not quite sure how one would implement such, though I'm very open to suggestions.
Notes
MatchingCharacterPainter
is using theStyledText.getTextBounds()
method to determine the width of the highlight box to draw. This method calculates width based on runs of text, and thus includes the method parameter hints in that width.This change instead moves to using
GC.textExtent()
to determine the width of text to highlight, ensuring that only the desired character is highlighted. The character width to highlight was already hard-coded to1
, so now we just pull a single character of text from the desired offset, and pass it toGC.textExtent()
to get its width.Testing
Manual testing
Tested on Windows, running in a normal window
Tested on Windows, on a desktop with 200% font scaling enabled:
Unit testing
I didn't find existing unit tests for
MatchingCharacterPainter
, and am not quite sure how one would implement such, though I'm very open to suggestions.