editor: Represent scroll offset with more precision (#39367)

Closes #5355

Release Notes:

- Fixed rendering glitches with files with more than 16 million lines
(that occured due to floating number rounding errors).

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
Piotr Osiewicz
2025-10-02 23:04:31 +02:00
committed by GitHub
co-authored by Smit Barmase
parent 4c35274b6e
commit d359a814f8
61 changed files with 711 additions and 530 deletions
+2 -2
View File
@@ -140,8 +140,8 @@ impl TextSize {
Self::Default => rems_from_px(14.),
Self::Small => rems_from_px(12.),
Self::XSmall => rems_from_px(10.),
Self::Ui => rems_from_px(theme_settings.ui_font_size(cx).into()),
Self::Editor => rems_from_px(theme_settings.buffer_font_size(cx).into()),
Self::Ui => rems_from_px(theme_settings.ui_font_size(cx)),
Self::Editor => rems_from_px(theme_settings.buffer_font_size(cx)),
}
}
}
+2 -2
View File
@@ -10,8 +10,8 @@ pub const BASE_REM_SIZE_IN_PX: f32 = 16.;
///
/// For instance, instead of writing `rems(0.875)` you can write `rems_from_px(14.)`
#[inline(always)]
pub fn rems_from_px(px: f32) -> Rems {
rems(px / BASE_REM_SIZE_IN_PX)
pub fn rems_from_px(px: impl Into<f32>) -> Rems {
rems(px.into() / BASE_REM_SIZE_IN_PX)
}
/// Returns a [`Length`] corresponding to the specified percentage of the viewport's width.