Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix boundary condition in StyledText#getTextBounds #1328

Merged

Conversation

tobiasmelcher
Copy link
Contributor

StyledText#getTextBounds returns 0x7fffffff as x value if input parameters start and end have the same value and line at the given offset is empty. This looks not correct from my point of view.
This has the effect that code minings in org.eclipse.jface.text.examples.codemining.CodeMiningDemo are not drawn correctly. Two LineHeaderCodeMinings to be drawn on the same line are then drawn on top of each other (see screenshot at eclipse-platform/eclipse.platform.ui#2024).

@iloveeclipse
Copy link
Member

Any chance for a test case / reproducer?

Copy link
Contributor

github-actions bot commented Jul 8, 2024

Test Results

   478 files  ±0     478 suites  ±0   8m 37s ⏱️ -5s
 4 138 tests +1   4 130 ✅ +1   8 💤 ±0  0 ❌ ±0 
16 345 runs  +4  16 253 ✅ +4  92 💤 ±0  0 ❌ ±0 

Results for commit ded8838. ± Comparison against base commit 8eda32a.

♻️ This comment has been updated with latest results.

@tobiasmelcher tobiasmelcher force-pushed the StyledText_getTextBounds branch from 3a24f9e to 72c11cb Compare July 9, 2024 13:09
@tobiasmelcher
Copy link
Contributor Author

Any chance for a test case / reproducer?

I added a unit test in Test_org_eclipse_swt_custom_StyledText and a standalone application org.eclipse.swt.examples.texteditor.mining.CodeMining which shows the problem scenario.

Running org.eclipse.swt.examples.texteditor.mining.CodeMining without the fix in StyledText#getTextBounds results in two overlapping minings:
two_minings_overlap

With the fix, the two minings are rendered properly:
two_minings_not_overlap

I know that I introduced a cycle by adding a dependency to org.eclipse.jface.text in org.eclipse.swt.examples. I just wanted to show you the scenario in a reproducible app. Should I remove the CodeMining application from the examples plugin once you were able to reproduce it?

@tobiasmelcher tobiasmelcher force-pushed the StyledText_getTextBounds branch from 72c11cb to ded8838 Compare July 12, 2024 07:20
@BeckerWdf BeckerWdf merged commit 9cf9fa7 into eclipse-platform:master Jul 12, 2024
14 checks passed
@BeckerWdf BeckerWdf added this to the 4.33 M2 milestone Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants