-
Notifications
You must be signed in to change notification settings - Fork 109
Include last line during folding #2569
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
base: master
Are you sure you want to change the base?
Conversation
|
Looks good, I tested only with the snippet provided in #2439 (comment) and I like what I see. I would get rid of the parameter though, it's unnecessary complexity. Thank you, @danthe1st ! |
So you think it makes more sense to always include the last line in the folding region? |
|
I think there is no need burden the user with yet another configuration. I would simply make a decision (show it/don't show it) and ship it. But that's just my opinion. In any case, a committer would have to make a decision about this in the end. Maybe @iloveeclipse ? |
441a558 to
460f94c
Compare
I removed that option with https://github.com/eclipse-jdt/eclipse.jdt.ui/compare/92b92fce70fc5864a2491444207d12b1e81e94f6..484b44fd3cfa93a22b5c15b9f804e5bae8e37f11. I've also some more testing and fixed a remaining issue where certain statements ending with a |
Nevermind, that was #2596 and I was able to fix it by by treating commas in the same way as semicolons so it makes more sense to do it in this PR. However, one thing that still needs to be done is adapting all the tests since they expect the last line to be excluded. |
460f94c to
f918103
Compare
|
Thank you for looking into this, @danthe1st 💪 |
|
Note the following (change of behavior with extended folding/folding of control structures): My current approach (not fully committed yet) also folds the last line with some extended folding control structures where there is something after the region ends: try { // not collapsed (start)
... // collapsed, region end
} catch(SomeException e) { // not collapsed by first region, second region starts here
// collapsed
} // folding region enddo { // not collapsed (start)
... // collapsed, region end
} while(...); // Not collapsedFor methods and other control structures, the last line is included: void something() { // not collapsed, region start
... // collapsed
} // collapsed, region endwhile(...) { // not collapsed, region start
... // collapsed
} // collapsed, region endFurthermore, anything that consists of only two lines is now folded: void a() { // folding region here
} // this would be collapsed now because it is a region consisting of 2 linesAlso, should Also, for things like while(...) {
...
} // this is not collapsed
// indentation ends here
while(...) {
...
} // this is collapsed???
// indentation ends hereShould I remove that behavior as well (it should be as simple as just removing the whole Note: With my (current) approach, comments would prevent the last line from being folded. |
I am not sure I really understand that reasoning given that it only seems to change the line with the Also, it seems like in cases like that, the while(i==2) {
// ...
} if(i==2) {
// ...
} |
d64b430 to
b34833d
Compare
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
63dad2c to
1c2dbba
Compare
|
@fedejeanne Sorry, I didn't have the time and motivation to work on this until now. I now changed it to just not affect control structures (i.e. the things added by extended folding, e.g. The tests should document the effects of my changes. The changes related to custom folding regions were because the changes broke what was added (as noticed by the tests) in #2282 (and that's what I wasn't able to fix last time). |
056f8eb to
2d428bb
Compare



Fixes #2439
Fixes #2596
What it does
When extended folding was introduced, both the existing and extended folding mechanisms were changed to generally not include the last line (with a few exceptions).
If I remember correctly, this was done to prevent hiding the
b()method in situations like this:This PR fixes this regression by including the last line in the folding regions where appropriate. If there is anything additional in the same line as the end of the folding region (e.g. the
b()method above), the last line won't be included.This change applies to both the "old" and "extended" folding mechanisms but the extended folding will not include the last line in the folding regions in control structures other than lambdas (unless someone tells me when exactly these should be included).
How to test
}should be hiddenAuthor checklist