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:
co-authored by
Smit Barmase
parent
4c35274b6e
commit
d359a814f8
@@ -1,20 +1,20 @@
|
||||
use gpui::Pixels;
|
||||
use gpui::{Pixels, px};
|
||||
|
||||
pub struct SearchInputWidth;
|
||||
|
||||
impl SearchInputWidth {
|
||||
/// The container size in which the input stops filling the whole width.
|
||||
pub const THRESHOLD_WIDTH: f32 = 1200.0;
|
||||
pub const THRESHOLD_WIDTH: Pixels = px(1200.0);
|
||||
|
||||
/// The maximum width for the search input when the container is larger than the threshold.
|
||||
pub const MAX_WIDTH: f32 = 1200.0;
|
||||
pub const MAX_WIDTH: Pixels = px(1200.0);
|
||||
|
||||
/// Calculates the actual width in pixels based on the container width.
|
||||
pub fn calc_width(container_width: Pixels) -> Pixels {
|
||||
if container_width.0 < Self::THRESHOLD_WIDTH {
|
||||
if container_width < Self::THRESHOLD_WIDTH {
|
||||
container_width
|
||||
} else {
|
||||
Pixels(container_width.0.min(Self::MAX_WIDTH))
|
||||
container_width.min(Self::MAX_WIDTH)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user