Skip to content

Conversation

@danthe1st
Copy link
Contributor

As noticed in #3074 (comment) by @totomomo18, there are situations where the projection-based folding introduced in #3074 hides the last line where it should be shown. In that example, it was due to Windows line endings (\r\n) where the last line was missing and it only moved past the \r but not the \n (it didn't account for the second character).

However, there is another situation where this can happen which is the case if there is additional (non-whitespace) text in the last line after the visible region. In the following example, assume that the visible region starts with { and ends with }:

{
    // ...
} // additional text here

Here, the } would be hidden.

An example where this could happen with JDT is enum constants (because of the , after the constants):

enum ABC {
    SOME_CONSTANT,
    OTHER_CONSTANT
}

The problem with these situations is that projections/folding cannot hide partial lines at the end so it has to show the entire last line. When I implemented #3074, I was assuming that this was an issue with whitespace at the end but I didn't account for further text (it worked perfectly fine with comments and other things in JDT because comments at the end seem to be included in the visible regions set by JDT).

This change ensures that setting the visible region with projections enabled does not hide the last line in case there is additional text at the end of the line or the file is using Windows line endings by fixing the logic for computing the end of the visible region.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

Test Results

 3 018 files  ± 0   3 018 suites  ±0   2h 16m 10s ⏱️ - 1m 14s
 8 253 tests + 4   8 005 ✅ + 4  248 💤 ±0  0 ❌ ±0 
23 679 runs  +12  22 888 ✅ +12  791 💤 ±0  0 ❌ ±0 

Results for commit e3ed532. ± Comparison against base commit d145b2c.

♻️ This comment has been updated with latest results.

@danthe1st
Copy link
Contributor Author

Test failure seems to be #3581

This change ensures that setting the visible region with projections
enabled does not hide the last line in case there is additional text at
the end of the line or the file is using Windows line endings.
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.

1 participant