Assign gutter widht on editor view when painting element

This commit is contained in:
Max Brunsfeld 2023-11-08 17:01:50 -08:00
parent 15f6fbf53b
commit 86865431b9
2 changed files with 5 additions and 4 deletions

View file

@ -674,6 +674,7 @@ pub struct Editor {
next_inlay_id: usize,
_subscriptions: Vec<Subscription>,
pixel_position_of_newest_cursor: Option<gpui::Point<Pixels>>,
gutter_width: Pixels,
style: Option<EditorStyle>,
}
@ -1984,6 +1985,7 @@ impl Editor {
inlay_hint_cache: InlayHintCache::new(inlay_hint_settings),
gutter_hovered: false,
pixel_position_of_newest_cursor: None,
gutter_width: Default::default(),
style: None,
_subscriptions: vec![
cx.observe(&buffer, Self::on_buffer_changed),
@ -9771,14 +9773,12 @@ impl InputHandler for Editor {
let scroll_position = snapshot.scroll_position();
let scroll_left = scroll_position.x * em_width;
// todo!() How do we actually get the gutter margin here?
let gutter_margin = px(84.46154);
let start = OffsetUtf16(range_utf16.start).to_display_point(&snapshot);
let end = OffsetUtf16(range_utf16.end).to_display_point(&snapshot);
let start_y = line_height * (start.row() as f32 - scroll_position.y);
let end_y = line_height * (end.row() as f32 - scroll_position.y);
let start_x = snapshot.x_for_point(start, &text_layout_details) - scroll_left + gutter_margin;
let start_x =
snapshot.x_for_point(start, &text_layout_details) - scroll_left + self.gutter_width;
let end_x = snapshot.x_for_point(end, &text_layout_details) - scroll_left;
Some(Bounds::from_corners(

View file

@ -1468,6 +1468,7 @@ impl EditorElement {
gutter_margin = Pixels::ZERO;
};
editor.gutter_width = gutter_width;
let text_width = bounds.size.width - gutter_width;
let overscroll = size(em_width, px(0.));
let snapshot = {