-
Notifications
You must be signed in to change notification settings - Fork 226
hide projection annotations outside of the current visible region #3423
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
hide projection annotations outside of the current visible region #3423
Conversation
|
In general works as advertised, thanks. If you could figure out how to add test for that, it would be great. |
b2d270d to
f1879fb
Compare
|
@danthe1st There is a problem. If one collapses a region around an element (e.g. method) and then selects the method, it shows the collapsed region comment but no annotation. If one then selects the class, the region comment has a plus, though it is already expanded and the weird text at end of folded lines is all the place. Clicking on the plus resets everything back to where it is supposed to be. |
I see. It might be a possibility to automatically expand regions like this in such a situation (I guess selecting a visible region that is practically collapsed doesn't make much sense). |
2bf7aa8 to
67a1490
Compare
|
@jjohnstn I attempted to provide a fix for it by automatically expanding regions that border the current folding region. However, I didn't get to test it properly yet (I plan to do that tomorrow). I think this should be the best behavior for anything running into that behavior (not just JDT). |
67a1490 to
9afcd76
Compare
Projection regions that overlap with parts of the file outside of the current visible region cannot be collapsed hence their annotations should not be painted.
9afcd76 to
c7d5ff6
Compare
|
I improved and tested my fix to the problem mentioned by @jjohnstn and I adjusted this PR (both the code/tests and the PR description). While testing, I think I found another issue but I think that's unrelated to this PR and should probably be fixed on its own. |
|
Thanks. |
In #3074, I prevented collapsing and expanding projection regions that overlap with parts of the file outside of the current visible region.
However, this does not prevent the projection annotation from being shown in the editor. This PR changes that behavior and ensures these annotations (that cannot be collapsed or expanded) cannot be shown.
To prevent showing empty "files" in the editor which cannot be expanded, I also changed the code for setting the visible region to expand any surrounding or "bordering" projection regions.
manual Testing
This can be tested by setting up an editor with content similar to the following:
If the visible region is configured from
visible_region_starttovisible_region_endand a projection annotation is created betweenprojection_startandprojection_end(in both cases, these texts are inclusive), there is an annotation atprojection_startwhich cannot be collapsed.If I figure out how to test whether an annotation is drawn, I can provide a proper test case.
Here is a test case for manual inspection:
This is what it should look like:

With the other version (or without this change), there is a projection annotation shown on the right:

I also added automated tests for it.
JDT example (for context)
More or less eclipse-jdt/eclipse.jdt.ui#2302 (comment), this can be seen with JDT using eclipse-jdt/eclipse.jdt.ui#2302 by enabling Window > Preferences > Java > Editor > Only show the selected Java Element as well as Window > Preferences > Java > Editor > Folding > Enable folding of custom regions
Open a Java file with the following code (adapted from eclipse-jdt/eclipse.jdt.ui#2302 (comment)):
When selecting
a()in the editor, it only showsWithout this PR, the
// regionhas a folding annotation on the right which cannot be used. With this PR, this region is used. However, it is still present when the whole class is shown.