As discussed and explained in
https://github.com/zed-industries/zed/pull/26893#discussion_r2074102719
This PR fixes an issue where we would have zero-divisions during
scrollbar layouting for small files.
This happened due to the fact that for small files,
9c1b2afa49/crates/editor/src/element.rs (L8562-L8563)
would be `NaN`, since `(total_text_units - text_units_per_page).max(0.)`
would return `0.`, which we would divide by.
However, this was neccessary to be in place, as this prevented the
scroll thumb from being rendered for small files: Due to this being
`NaN`, the thumb origin would be `Pixels(NaN)`, which prevented the
rendering of the scrollbar thumb.
This PR fixes this behavior by accounting for this scenario and changing
the thumb bounds to be an `Option<Bounds<Pixels>>` instead. This
furthermore has the advantage that we have to compute the thumb only
once and storing it in the layout, which was previously not possible.
Most notably, this enables scrollbar markers to show for smaller files:
https://github.com/user-attachments/assets/9fa5d240-8795-4fae-9933-aed144df4f5e
Currently, no markers are shown due to the fact that `Pixels(NaN)` is
set as the origin point.
Also, I changed that the cursor style will only be changed on the
scrollbar hitbox when we will actually show a thumb. This way, for small
files (where viewport > content size) the cursor will not change when a
user hovers with their mouse over the scrollbars hitbox.
Theoretically, I could also include the change mentioned in
https://github.com/zed-industries/zed/pull/26893#discussion_r2076316956
here. Given the introduction of the minimap as well as #29316 and the
cursor style taken care of here, removing the guard would not change
anything and creates the possibility to soon introduce scrollbars for
auto height editors. Please let me know whether we want to have this in
this PR or whether I shall create a seperate one.
Release Notes:
- Enabled scrollbar marker rendering for small files.