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
@@ -3,7 +3,7 @@ use base64::{
|
||||
Engine as _, alphabet,
|
||||
engine::{DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig},
|
||||
};
|
||||
use gpui::{App, ClipboardItem, Image, ImageFormat, Pixels, RenderImage, Window, img};
|
||||
use gpui::{App, ClipboardItem, Image, ImageFormat, RenderImage, Window, img};
|
||||
use std::sync::Arc;
|
||||
use ui::{IntoElement, Styled, div, prelude::*};
|
||||
|
||||
@@ -72,17 +72,17 @@ impl Render for ImageView {
|
||||
fn render(&mut self, window: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
let line_height = window.line_height();
|
||||
|
||||
let (height, width) = if self.height as f32 / line_height.0 == u8::MAX as f32 {
|
||||
let height = u8::MAX as f32 * line_height.0;
|
||||
let (height, width) = if self.height as f32 / f32::from(line_height) == u8::MAX as f32 {
|
||||
let height = u8::MAX as f32 * line_height;
|
||||
let width = self.width as f32 * height / self.height as f32;
|
||||
(height, width)
|
||||
} else {
|
||||
(self.height as f32, self.width as f32)
|
||||
(self.height.into(), self.width.into())
|
||||
};
|
||||
|
||||
let image = self.image.clone();
|
||||
|
||||
div().h(Pixels(height)).w(Pixels(width)).child(img(image))
|
||||
div().h(height).w(width).child(img(image))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ impl Render for TerminalOutput {
|
||||
let cell_width = text_system
|
||||
.advance(font_id, font_pixels, 'w')
|
||||
.map(|advance| advance.width)
|
||||
.unwrap_or(Pixels(0.0));
|
||||
.unwrap_or(Pixels::ZERO);
|
||||
|
||||
canvas(
|
||||
// prepaint
|
||||
|
||||
Reference in New Issue
Block a user